§ ITPOW >> 文档 >> CSS

有趣的 CSS 3-background

作者:vkvi 来源:ITPOW(原创) 日期:2017-12-3

指定多个背景

使用逗号隔开,比如:

background:url(../img/top-left.png) no-repeat top left,
           url(../img/top-right.png) no-repeat top right,
           url(../img/bottom-left.png) no-repeat bottom left,
           url(../img/bottom-right.png) no-repeat bottom right;

指定背景大小

background-size:contain; 缩小图像长边,使容器完整包含图像。

background-size:cover; 放大图像短边,使短边完全撑满容器。

注意:background-size 必须写在 background 的后面,奇葩。至少在 Chrome 模拟手机中如此。

更多请参见:说说 CSS 的 background-size

相关文章