- HTML中文网
- 联系QQ:88526
- QQ交流群

- 微信公众号

background-repeat属性
含义:
background-image 属性设置如何平铺对象的 。
默认情况下,重复background-image的垂直和水平方向。
浏览器支持:
表格中的数字表示支持该属性的第一个浏览器版本号
属性 | ![]() | ![]() | ![]() | ![]() | ![]() |
---|---|---|---|---|---|
background-repeat | 4.0 | 1.0 | 1.0 | 1.0 | 3.5 |
注意:IE8以及更早版本的浏览器不支持多个背景图像在一个元素。
IE7和更早的版本不支持"inherit(继承)"的值。 IE8需要定义!DOCTYPE。 IE9支持"inherit(继承)"
CSS语法:
background-repeat:repeat|no-repeat|inherit
注:background-position属性设置背景图像位置。如果指定的位置是没有任何背景,图像总是放在元素的左上角。
属性值:
值 | 描述 |
repeat | 背景图像将向垂直和水平方向重复,默认值 |
repeat-x | 只有水平位置会重复背景图像 |
repeat-y | 只有垂直位置会重复背景图像 |
no-repeat | background-image不会重复 |
inherit | 指定background-repea属性设置应该从父元素继承 |
<!DOCTYPE html> <html> <head> <style> p{width:200px; height:100px; background-image: url("images/鸟.png"); background-repeat: no-repeat; } div{ width:200px; height: 150px; background-image: url("images/鸟.png"); background-repeat: repeat-y; } </style> </head> <body> <h3>图片不重复:</h3> <p></p> <h3>图片沿y轴重复:</h3> <div></div> </body> </html>
点击 "运行实例" 按钮查看在线实例
效果图:
推荐手册