0
.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;
}
4

1 回答 1

0

对我来说工作得很好,也许你没有将图像保存为.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>

于 2015-01-31T12:16:47.443 回答