1.<html>
<body>
<table height="30%" width="100%" bgcolor =blue><tr><td></td></tr></table>
<table height="40%" width="100% bgcolor =yellow ><tr><td></td></tr></table>
<table height="30%" width="100% bgcolor =red><tr><td></td></tr></table>
</body>
</html>
这样直接写成HTML在IE里效果是对的,就是上面30%,中间40%,下边30%.但放到ASPX里确无效了,请问为什么.
<body>
<table height="30%" width="100%" bgcolor =blue><tr><td></td></tr></table>
<table height="40%" width="100% bgcolor =yellow ><tr><td></td></tr></table>
<table height="30%" width="100% bgcolor =red><tr><td></td></tr></table>
</body>
</html>
这样直接写成HTML在IE里效果是对的,就是上面30%,中间40%,下边30%.但放到ASPX里确无效了,请问为什么.
<div id="TestDiv" style="OVERFLOW-Y: auto; OVERFLOW-X: auto; POSITION: relative; WIDTH: 100%;Height:300px; CLIP: rect(auto auto auto auto)">
<asp:datagrid id="dgList" .......>
</div>
以上DIV里放了一个DATAGRID,当DATAGRID里的内容过长时候,系统会自动把页面撑大,明明被DIV包注了,为什么会撑爆啊? 请问设置的DIV WIDTH: 100%; 为什么无效,要怎样搞,才有效果?
<div style="width:100%;height:40%"><table height="40%" width="100% bgcolor =yellow ><tr><td></td></tr></table></div> <div style="width:100%;height:30%"> <table height="30%" width="100% bgcolor =red><tr><td></td></tr></table></div>
==>
只能说你没放对
如果你将这个html页面更名为aspx
应该是一样的效果,你的aspx页面中有其它的内容影响了布局
<div id="TestDiv" style="OVERFLOW-Y: auto; OVERFLOW-X: auto; POSITION: relative; WIDTH: 100%;Height:300px; CLIP: rect(auto auto auto auto)">
<asp:datagrid id="dgList" .......>
</div>
以上DIV里放了一个DATAGRID,当DATAGRID里的内容过长时候,系统会自动把页面撑大,明明被DIV包注了,为什么会撑爆啊? 请问设置的DIV WIDTH: 100%; 为什么无效,要怎样搞,才有效果? 这个DataGrid是自己可以自定义宽度的 你把数据长点的字段设长点,数据短的字段设短点...
1个一个来,以下是我第1题的所有代码...大家帮忙看看
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="test.aspx.cs" Inherits="SystemFolder_LogIn_Default" %>
<!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>test</title>
</head>
<body style="text-align:center">
<form id="form1" runat="server">
<div>
<table height = 100% width = 100%>
<tr>
<td valign =middle align =center >
<table height="30%" bgcolor =yellow><tr><td></td></tr></table>
<table height="40%" width = 100% border="0" >
省略...
</table>
<table height="30%" bgcolor =red><tr><td></td></tr></table>
</td>
</tr>
</table>
</div>
</form>
</body>
</html>
属性与值之间不要有空格。
<html xmlns="http://www.w3.org/1999/xhtml" >这段代码和Html文件是否一样,另外你删掉Form看看效果是不是一样
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>WebForm1</title>
<meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<table height="30%" width="100%" bgcolor="blue">
<tr>
<td></td>
</tr>
</table>
<table height="40%" width="100%" bgcolor ="yellow"><TR>
<TD></TD>
</TR>
</TABLE> <table height="30%" width="100%" bgcolor ="red"><TR>
<TD></TD>
</TR>
</TABLE></form>
</body>
</HTML>看一下是不是建站时出错了
我这里没有问题
我看到问题了
width="100%"
width="100%" 第二个和第三个的这里有问题少了"
,如下例所示
<%@ Page Language="C#" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><script runat="server">
void Page_Load(object sender, EventArgs e) {
int[] arr = new int[100];
for (int i = 0; i < arr.Length; i++) {
arr[i] = i;
}
dg1.DataSource = arr;
dg1.DataBind();
}
</script><html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
<style type="text/css">
.dgclip{
position: absolute;
clip: rect(0 auto 300px 0);
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:DataGrid runat="server" id="dg1" CssClass="dgclip">
</asp:DataGrid>
</div>
</form>
</body>
</html>
最好 是 把下面的```
<table height="30%" width="100%" bgcolor =blue><tr><td></td></tr></table>
<table height="40%" width="100%" bgcolor =yellow ><tr><td></td></tr></table>
<table height="30%" width="100%" bgcolor =red><tr><td></td></tr></table>
这写 标记
放在 ASPX 的 BODY 中 就可以了```应该 可以解决``` (在放了 之后 看代码下面是否 有下划线`)
没 下化线的 话```应该 就OK 落````
<body leftmargin="0" rightmargin="0" topmargin="0" bottommargin="0">
<table width="100%" height="100%">
<tr height="30%">
<td bgcolor="blue">
</td>
</tr>
<tr width="40%">
<td bgcolor="yellow">
<div style="overflow-y: auto; overflow-x: auto;
width: 100%; height: 100%; clip: rect(auto auto auto auto)">
adflasdfasd<br />
adflasdfasd<br />
adflasdfasd<br />
adflasdfasd<br />
adflasdfasd<br />
adflasdfasd<br />
adflasdfasd<br />
adflasdfasd<br />
adflasdfasd<br />
adflasdfasd<br />
adflasdfasd<br />
adflasdfasd<br />
adflasdfasd<br />
adflasdfasd<br />
adflasdfasd<br />
adflasdfasd<br />
adflasdfasd<br />
adflasdfasd<br />
adflasdfasd<br />
adflasdfasd<br />
adflasdfasd<br />
adflasdfasd<br />
adflasdfasd<br />
adflasdfasd<br />
adflasdfasd<br />
adflasdfasd<br />
adflasdfasd<br />
adflasdfasd<br />
adflasdfasd<br />
adflasdfasd<br />
adflasdfasd<br />
adflasdfasd<br />
adflasdfasd<br />
adflasdfasd<br />
adflasdfasd<br />
adflasdfasd<br />
adflasdfasd<br />
adflasdfasd<br />
adflasdfasd<br />
</div>
</td>
</tr>
<tr width="30%">
<td bgcolor="red">
</td>
</tr>
</table>
</body>
</html>
<body leftmargin="0" rightmargin="0" topmargin="0" bottommargin="0">
<table width="100%" height="100%">
<tr height="30%">
<td bgcolor="blue">
</td>
</tr>
<tr width="40%">
<td bgcolor="yellow">
<div style="overflow-y: auto; overflow-x: auto; width: 900px; height: 100%;">
adflasdfasdadflasdfasdadflasdfasdadflasdfasdadflasdfasdadflasdfasdadflasdfasdadflasdfasdadflasdfasdadflasdfasdflasdfasdadflasdfasdadflasdfasdadflasdfasdadflasdfasdadflasdfasdflasdfasdadflasdfasdadflasdfasdadflasdfasdadflasdf
adflasdfasd<br />adflasdfasd<br />adflasdfasd<br />
adflasdfasd<br />adflasdfasd<br />adflasdfasd<br />adflasdfasd
<br />adflasdfasd<br />adflasdfasd<br />adflasdfasd<br />adflasd
fasd<br />adflasdfasd<br />adflasdfasd<br />adflasdfasd<br />adfl
asdfasd<br />adflasdfasd<br />adflasdfasd<br />adflasdfasd<br />
adflasdfasd<br />adflasdfasd<br />adflasdfasd<br />adflasdfasd
<br />adflasdfasd<br />adflasdfasd<br />adflasdfasd<br />adflasd
fasd<br />adflasdfasd<br />adflasdfasd<br />adflasdfasd<br />adfla
sdfasd<br />adflasdfasd<br />adflasdfasd<br />adflasdfasd<br />adfl
asdfasd<br />adflasdfasd<br />adflasdfasd<br />adflasdfasd<br />adfl
asdfasd<br />adflasdfasd<br />adflasdfasd<br />adflasdfasd<br />adfl
asdfasd<br />adflasdfasd<br />adflasdfasd<br />adflasdfasd<br />adfl
</div>
</td>
</tr>
<tr width="30%">
<td bgcolor="red">
</td>
</tr>
</table>
</body>
</html>