background-size使用时的注意点

background-size要写在background-image后面,否则background-size不会生效

.comment .clist .item code {
    background-size: 0.42rem;
    background: url(/img/zan1.png) no-repeat;
}

这样写,background-size是不生效的

必须这样写:

.comment .clist .item code {
    background: url(/img/zan1.png) no-repeat;
    background-size: 0.42rem;
}

如果一个后面的一个样式修改了background-image,则background-size也要一起修改,否则原先设置的background-size会失效

比如,原先的样式如下:

.comment .clist .item code {
    background: url(/img/zan1.png) no-repeat;
    background-size: 0.42rem;
}

现在有个操作修改了background-image的值

.comment .clist .item code {
    background: url(/img/zan2.png) no-repeat;
}

则原先设置的background-size会失效,需要重新设置

.comment .clist .item code {
    background: url(/img/zan2.png) no-repeat;
    background-size: 0.42rem;
}

 

posted @ 2017-04-05 17:10  hahaha222  阅读(1337)  评论(0编辑  收藏  举报