.headImg {
padding: 8% 0px 13% 0px;
background: url(img/bg.jpeg);
background-position: center center;
background-size: 100% auto;
}
其中background-size中,第一个参数表示width,第二个参数表示height,可根据需要将auto改为具体值
<div class="headImg">
</div>
如果图片为底层,其上有内容,则在上述<div>和</div>之间插入代码;如果图片和其它网页内容上下排列,即图片上无内容,则在</div>之后加入代码。