HTML
<div class="bg">
// some code and text nothing crazy
</div>
CSS
.bg {
background-image: url("color.jpg");
background-position: top;
margin-top: -75px;
}
我的背景图片和浏览器边缘之间的两边都出现了白边。只是想让我的背景图片延伸到边缘……此时我已经尝试了过多的 . .. 背景位置,只是 reg position: relative/fixed 等。似乎都不起作用。我也试过 max-width 但似乎没有帮助。感觉我错过了一些明显的东西?
最佳答案
尝试去除 body 的填充和边距:
html, body {
margin:0;
padding:0;
}
关于css - div类中的背景图像不会拉伸(stretch)到浏览器的全宽,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32974457/