【问题标题】:CSS - Background-size not working on jpg extensionCSS - 背景大小不适用于 jpg 扩展
【发布时间】:2015-01-31 10:48:11
【问题描述】:
.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;
}

【问题讨论】:

    标签: css background-size


    【解决方案1】:

    对我来说非常好用,也许您没有将图像保存为 .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>

    【讨论】:

    • @user3187715 - 不要忘记点击您发现的回复下方的勾号:)
    • 我不知道如何点击 :D 对不起,我迟到了
    猜你喜欢
    • 2014-09-01
    • 1970-01-01
    • 1970-01-01
    • 2018-01-03
    • 1970-01-01
    • 2015-08-21
    • 2011-06-30
    • 1970-01-01
    • 2021-11-13
    相关资源
    最近更新 更多