.baner {
background-image: url('ban.jpg');
background-size: cover;
background-repeat: no-repeat;
position: fixed;
width: 100%;
height: 35%;
top: 60px;
}
不会覆盖这个背景,但是当我做 png
图像时它起作用了,我不明白为什么:
.baner {
background-image: url('ban.png');
background-size: cover;
background-repeat: no-repeat;
position: fixed;
width: 100%;
height: 35%;
top: 60px;
}
最佳答案
对我来说效果很好,也许你没有将图像保存为 .jpg
或其他...
div.one {
width:100px;
height:100px;
background-image:url(http://placekitten.com.s3.amazonaws.com/homepage-samples/408/287.jpg);
background-position:center;
background-repeat:no-repeat;
background-size:cover;
}
div.two {
width:500px;
height:500px;
background-image:url(http://placekitten.com.s3.amazonaws.com/homepage-samples/408/287.jpg);
background-position:center;
background-repeat:no-repeat;
background-size:cover;
}
<div class="one">
</div>
<div class="two">
</div>
关于CSS - 背景大小不适用于 jpg 扩展,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28250730/