在CSS中,如何使div达到整个页面的高度?
我想让这个div占据整个网页的空间,并在其中放一个背景图像。
发布于 2013-08-15 03:51:38
小提琴样本:http://jsfiddle.net/apTFp/
div{
position:absolute;
top:0px;
bottom:0px;
left:0px;
right:0px;
background-color:#eeeeee;
}(这应有效:)
发布于 2013-08-15 03:53:58
你能做到的
#mainContainer {
width: 100%;
height: 100%;
background: url('imagePath'); //you can add a repeat or no repeat here
}希望它对身体有帮助,或者说你可以对身体进行样式化,这样你就不会再指定宽度和高度了,而只是背景图像。
发布于 2013-08-15 03:55:05
一开始不需要一个div
试一试
<body style="position: relative; margin: 0; background-color: Blue;">
<p>
Hello
</p>
</body>当然,将背景颜色改为背景图像。
https://stackoverflow.com/questions/18246035
复制相似问题