如何设置像这张照片的全宽背景?

时间:2015-05-03 07:11:49

标签: html css background

enter image description here

如您所见,有一种背景图像有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>
&#13;
&#13;
&#13;

但显然它并没有像预期的那样发挥作用。我在这里错过了什么?

1 个答案:

答案 0 :(得分:0)

&#13;
&#13;
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;
}
&#13;
<body>
  <!-- upper section -->
   <div class="upper">
    This is the upper section
	</div>
<!--end upper section-->

</body>
&#13;
&#13;
&#13;