如您所见,背景图像有 4 种不同的颜色。我不确定如何将其转换为 HTML 以使其覆盖整个页面(水平)。我有以下代码:
body{
background: url(http://uupload.ir/files/y7l4_bg.png) repeat-x;
}
.upper{
background: url(http://uupload.ir/files/ur8m_cloud.png);
height:600px;
}
<body>
<!-- upper section -->
<div class="upper">
This is the upper section
</div>
<!--end upper section-->
</body>
但显然它没有按预期工作。我在这里错过了什么?
最佳答案
body{
background: url(http://uupload.ir/files/y7l4_bg.png) repeat-x;
margin: 0;
padding: 0;
}
.upper{
background: url(http://uupload.ir/files/ur8m_cloud.png);
height:600px;
background-repeat:no-repeat;
background-position: center top;
background-size: contain;
}
<body>
<!-- upper section -->
<div class="upper">
This is the upper section
</div>
<!--end upper section-->
</body>
关于html - 如何设置像这张照片一样的全宽背景?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30011207/