请问我这样写对么?另外,为什么颜色部分充满屏幕不能给每个<tr>设置宽度100%?
来源:3-4 编程练习
慕大斯
2019-05-10 15:08:45
<!DOCTYPE html>
<html>
<head>
<title></title>
<meta charset="utf-8">
</head>
<body>
<table align="center" width="100%">
<tr bgcolor="pink" height="80px" ><td>页头</td></tr>
<tr bgcolor="white" height="10px"><td>1111</td></tr>
<tr bgcolor="orange">
<td>
<table align="center" width="1024px">
<tr>
<td width="240px" bgcolor="white">左侧内容</td>
<td width="20px"></td>
<td width="764px" bgcolor="white">右侧内容</td>
</tr>
</table>
</td>
</tr>
<tr height="10px" bgcolor="white"><td>1111</td></tr>
<tr bgcolor="black" height="80px"><td>1111</td></tr>
</table><!-- 在此编写代码 -->
</body>
</html>
1回答
学到后面的内边距之类的知识会讲到这点,主要是因为每个浏览器都会有自身的内外边距,所以我们设置的100%后,颜色并没有全部充满屏幕。后期我们自己写网页,都会首先清掉默认的内外边距的。
至于设置宽度100%,则是表示该元素相对于他的父元素宽度为100%。若给tr设置100%,table没有宽度,tr继承不了父级的宽。所以是不行的。
相似问题