我正在尝试创建多个宽度和高度均为 100% 的 div,但一直失败得很惨。示例:
<html>
<body>
<div id="wrapper">
<div id="1">100% height & width, all you can see when opening this file!</div>
<div id="2">I'll be 100% when you've scrolled #1 out of the window!</div>
</div>
</body>
</html>
此解决方案的 css 是什么?我似乎无法让它工作。
最佳答案
解决方案是首先为 margin
和 padding
重置默认值:
* {
margin:0;
padding:0;
}
其次让您的 html
和 body
成为 100%:
html, body {
height:100%;
}
然后是 div 的尺寸:
#wrapper, #one, #two {
width:100%;
height:100%;
}
您不能在第一个字符上为 id 或 class 分配数值
关于html - 多个垂直 100% 高度和宽度 div,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20433129/