您现在的位置是:首页 > 网站制作 > 前端设计

前端设计

css3背景(二)—background-repeat

杨青 2013-08-01前端设计

background-repeat

说明:设置或检索对象的背景图像如何铺排填充。必须先指定background-image属性。

提示:允许提供2个参数,如果提供全部2个参数,第1个用于横向,第二个用于纵向。如果只提供1个参数,则用于横向和纵向。特殊值repeat-x和repeat-y除外,因为repeat-x相当于repeat no-repeat,repeat-y相当于no-repeat repeat,即其实repeat-x和repeat-y等价于提供了2个参数值

语法:

background-repeat:<repeat-style> [ , <repeat-style> ]*

<repeat-style> = repeat-x | repeat-y | [repeat | space | round | no-repeat]{1,2}

取值:

repeat-x:背景图像在横向上平铺

repeat-y:背景图像在纵向上平铺

repeat:背景图像在横向和纵向平铺(默认值)

no-repeat:背景图像不平铺

round:背景图像自动缩放直到适应且填充满整个容器。

space:背景图像以相同的间距平铺且填充满整个容器或某个方向。

兼容性:

IE8及更早浏览器不支持为background-repeat定义2个参数值;不支持CSS3新增参数值round | space。

Firefox4.0-8.0不支持为background-repeat定义2个参数值;不支持CSS3新增参数值round | space。

Safari5.1已接受CSS3新增参数值round | space,但还未实现支持。

Chrome13.0-16.0已接受CSS3新增参数值round | space,但还未实现支持。

示例图片:

background-repeat:repeat-x

 

background-repeat:repeat-x; /* 背景图像在横向上平铺*/

 

background-repeat:repeat-y; /* 背景图像在纵向上平铺 */

 

background-repeat:repeat; /* 这是repeat的默认值 都平铺*/

 

background-repeat:no-repeat; /* 背景图像不平铺*/

文章评论