height:100% 在asp.net

wolf11th 2010-02-24 09:28:22
谁能帮我看看这段代码有什么问题?去掉form标签,就能height 100%,只要有form,就出问题
我其实想做的东西很简单,就是左边是导航栏,右面是内容页,导航栏和内容页都有自己的scroll bar,然后永远是100%高度,但是在asp。net的页面就是不行,我试了把html,body,form,div,table,tr,td都设成style:height 100%;,还是不行,请各位高手指点,谢谢


<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Test2.aspx.vb" Inherits="Test2" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<style type="text/css">
body, td, table, div, html
{
font-family: arial, verdana, helvetica, monospace;
color: #000080;
font-size: small;
height: 100%;
width: 100%;
}
form
{
height: 100%;
border: 0;
margin: 0px auto;
margin-top: 0px;
margin-left: 0px;
margin-right: 0px;
margin-bottom: 0px;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div style="height: 100%; background-color: lime">
sdaafsdf
</div>
</form>
</body>
</html>
...全文
248 16 打赏 收藏 转发到动态 举报
写回复
用AI写文章
16 条回复
切换为时间正序
请发表友善的回复…
发表回复
BruceLin2008 2010-07-22
  • 打赏
  • 举报
回复
[Quote=引用 5 楼 ynsky 的回复:]
如需要阅读该回复,请登录或注册CSDN!
[/Quote]

顶。。。
wolf11th 2010-02-26
  • 打赏
  • 举报
回复
在www.asp.net上有个印度人给了个方法,貌似可以:
01.<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
02.<html lang="en">
03.<head><title>100% Height CSS Layout</title>
04.<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
05.<style type="text/css">
06.* {
07.padding: 0;
08.margin: 0;
09.}
10.html, body {
11.height: 100%;
12.}
13.body {
14.font-family: "lucida sans", verdana, arial, helvetica, sans-serif;
15.font-size: 75%;
16.}
17.h1 {
18.font-size: 1.4em;
19.padding: 10px 10px 0;
20.}
21.p {
22.padding: 0 10px 1em;
23.}
24.#container {
25.min-height: 100%;
26.background-color: #DDD;
27.border-left: 2px solid #666;
28.border-right: 2px solid #666;
29.width: 676px;
30.margin: 0 auto;
31.}
32.* html #container {
33.height: 100%;
34.}
35.#form1
36.{
37. height:100%;
38. }
39.</style>
40.</head>
41.<body>
42.<form id="form1" runat="server" >
43.<div id="container">
44.<h1>100% Height Demo</h1>
45.
46.</div>
47.</form>
48.</body>
49.</html>


他主要用了如下就工作了
35.#form1
36.{
37. height:100%;
38. }



但我已经用了5楼兄弟的方法,貌似也很好。
总是谢谢大家了
jack15850798154 2010-02-24
  • 打赏
  • 举报
回复
引用 8 楼 javc 的回复:
引用 7 楼 jack15850798154 的回复:<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default3.aspx.cs" Inherits="Default3" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <head runat="server">     <title>无标题页 </title>     <style type="text/css">         body, td, table, div, html         {             font-family: arial, verdana, helvetica, monospace;             color: #000080;             font-size: small;             height: 100%;             width: 100%;         }         form         {             height: 100%;             border: 0;             margin: 0px auto;             margin-top:0px;             margin-left: 0px;             margin-right: 0px;             margin-bottom: 0px;         }     </style> </head> <body > <div style="height: 100%; background-color: lime"> <div style="height: 100%; background-color: lime">         sdaafsdf     </div> <form id="form1" runat="server">       </form>   </div> </body> </html> 你看看行吗???

我的ie6 肯定是不行了。


我只是多加了一个div啊。应该可以的啊。。。。。。。。
wolf11th 2010-02-24
  • 打赏
  • 举报
回复
为什么其他网站都行,唯独我的不行?这难道不是常见病吗?奇怪的是我去掉form里runat=“server”,就可以工作,页面布局也没问题,难道这是asp。net的bug?
wolf11th 2010-02-24
  • 打赏
  • 举报
回复
to 10楼,试了不行,换成 xhtml 3.0也不行
wolf11th 2010-02-24
  • 打赏
  • 举报
回复
7楼,不行啊,我必须把所有东西放在form里呢
Pig23 2010-02-24
  • 打赏
  • 举报
回复
把<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 去掉试试
javc 2010-02-24
  • 打赏
  • 举报
回复
<body style="height: 100%;width:100%;background-color: lime" >
<form id="form1" runat="server">
<table style="height: 100%;width:100% background-color: lime">
<tr>
<td>ddddd</td><td>ddddd</td>
</tr>
</table>
</form>
</body>
这样不知道可行
javc 2010-02-24
  • 打赏
  • 举报
回复
引用 7 楼 jack15850798154 的回复:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default3.aspx.cs" Inherits="Default3" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>无标题页 </title>
    <style type="text/css">
        body, td, table, div, html
        {
            font-family: arial, verdana, helvetica, monospace;
            color: #000080;
            font-size: small;
            height: 100%;
            width: 100%;
        }
        form
        {
            height: 100%;
            border: 0;
            margin: 0px auto;
            margin-top:0px;
            margin-left: 0px;
            margin-right: 0px;
            margin-bottom: 0px;
        }
    </style>

</head>
<body >
<div style="height: 100%; background-color: lime">
<div style="height: 100%; background-color: lime">
        sdaafsdf
    </div>
<form id="form1" runat="server">
   
  </form>
  </div>
</body>
</html>

你看看行吗???


我的ie6 肯定是不行了。
jack15850798154 2010-02-24
  • 打赏
  • 举报
回复
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default3.aspx.cs" Inherits="Default3" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>无标题页</title>
<style type="text/css">
body, td, table, div, html
{
font-family: arial, verdana, helvetica, monospace;
color: #000080;
font-size: small;
height: 100%;
width: 100%;
}
form
{
height: 100%;
border: 0;
margin: 0px auto;
margin-top:0px;
margin-left: 0px;
margin-right: 0px;
margin-bottom: 0px;
}
</style>

</head>
<body >
<div style="height: 100%; background-color: lime">
<div style="height: 100%; background-color: lime">
sdaafsdf
</div>
<form id="form1" runat="server">

</form>
</div>
</body>
</html>

你看看行吗???
YnSky 2010-02-24
  • 打赏
  • 举报
回复
想兼容IE.FF等.加个PX就行了.!!
YnSky 2010-02-24
  • 打赏
  • 举报
回复

document.getElementById("divName").style.height=document.documentElement.clientHeight;


divName换成你的div名字就行了!!
javc 2010-02-24
  • 打赏
  • 举报
回复
我以前试过,也是用js搞定。希望大牛能给出其他 方法
mengfanzongfox 2010-02-24
  • 打赏
  • 举报
回复
实在不行就height:200px;这样的格式!
imfor 2010-02-24
  • 打赏
  • 举报
回复
JS判断浏览器高度,然后写入height.
biaofanwo 2010-02-24
  • 打赏
  • 举报
回复
这个100%是跟它索要占的高度是一样的。。。。。。。。。。。。。

62,046

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧