【发布时间】:2016-12-03 17:49:07
【问题描述】:
我想在一个新网站的首页上放一张图片,覆盖总宽度,并根据您的分辨率改变大小,但仍保持水平居中。
这是我目前正在处理的网站:http://jonathan.ohrstrom.nu,我希望整个红色部分都被这张图片覆盖:http://jonathan.ohrstrom.nu/style/img/featured.jpg
我该怎么做?这是我想要图像的 div 的 css 代码:
.featured {
background-color: red;
width: 100%;
height: 700px;
position: absolute;
top: 0;
left: 0;
z-index: 1;
}
我试过这个没有成功:
.featured {
background-image: url(http://jonathan.ohrstrom.nu/style/img/featured.jpg) no-repeat;
width: 100%;
height: 700px;
size: cover;
position: absolute;
top: 0;
left: 0;
z-index: 1;
}
但这根本没有加载图像。如果没有no-repeat,则图像覆盖了整个宽度,但它会重复自身..
【问题讨论】: