背景图像宽度为1579px,因此,如果我们将浏览器拉伸至1920px,则背景图像高度会发生变化,即使我给出了固定的div宽度(650px)。 那么我怎样才能保持所有页面宽度相同的背景高度?如何在所有页面宽度上保持背景图像高度相同?
CSS:
.blue_bg1{
background: url("../images/hero-bg-espresso.jpg") no-repeat;
height: 650px;
background-position: center center;
background-size: 100% auto;
width: 100%;
}
只需设置一个固定的/ 100%的高度:) – 2014-12-05 18:04:54