我想显示一个 div,它具有背景颜色,高度和宽度设置为 100%,但没有内容。是否可以在不放置 的情况下做到这一点?里面?
编辑:感谢 Mark Biek 指出具有宽度和高度样式的空 div 显示了我的期望。我的 div 位于表格单元格中,但未显示。
<table style="width:100%">
<tr>
<th>Header</th>
<td><div id="foo"></div></td>
</tr>
</table>
最佳答案
这似乎适用于 Firefox、Safari、IE6 和 IE7。
<html>
<head>
<style>
#foo{
background: #ff0000;
width: 100%;
height: 100%;
border: 2px dashed black;
}
</style>
</head>
<body onload="">
<div id="foo"></div>
</body>
</html>
关于html - 有必要显示一个空的 <div> 吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/198058/