这是我的 div
的 css
。 © 期望背景填满整个屏幕,但它比我的屏幕分辨率大,所以出现底部滚动条
.hero-unit {
padding:60px;
margin-top: 60px;
background: url("../img/bar2.jpg") no-repeat scroll 0;
height:233px;
width:100%;
left:0px;
background-size: cover;
position:absolute;
background-color:#eeeeee;
}
最佳答案
你可以使用 box-sizing
-webkit-box-sizing: border-box; /* Safari/Chrome, other WebKit */
-moz-box-sizing: border-box; /* Firefox, other Gecko */
box-sizing: border-box;
这样一来,当您添加填充、边距或边框时,它不会影响宽度。 (这不适用于 IE7 及以下版本)
关于html - 我的 div 大于窗口的宽度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12677898/