background-repeat属性怎么用
导读: CSSbackground-repeat属性 作用:设置是否及如何重复背景图像。 基本语法: background-repeat:repeat|repeat-x|repeat-y|no-repeat; repea...
CSSbackground-repeat属性
作用:设置是否及如何重复背景图像。
基本语法:
background-repeat:repeat|repeat-x|repeat-y|no-repeat;
repeat:默认值,背景图像将向垂直和水平方向重复。
repeat-x:只有水平位置会重复背景图像。
repeat-y:只有垂直位置会重复背景图像。
no-repeat:设置背景图片不会重复。
说明:background-repeat属性定义了图像的平铺模式。从原图像开始重复,原图像由background-image定义,并根据background-position的值放置。
CSSbackground-repeat属性的使用示例
菜鸟教程(runoob.com)
.demo1{
width:400px;
height:150px;
border:1pxsolidred;
background-image:url('https://img.php.cn/upload/article/000/000/024/5c6a4428ea867709.png');
background-repeat:repeat;
}
.demo2{
width:400px;
height:100px;
border:1pxsolidred;
background-image:url('https://img.php.cn/upload/article/000/000/024/5c6a4428ea867709.png');
background-repeat:no-repeat;
}
.demo3{
width:400px;
height:150px;
border:1pxsolidred;
background-image:url('https://img.php.cn/upload/article/000/000/024/5c6a4428ea867709.png');
background-repeat:repeat-x;
}
.demo4{
width:400px;
height:400px;
border:1pxsolidred;
background-image:url('https://img.php.cn/upload/article/000/000/024/5c6a4428ea867709.png');
background-repeat:repeat-y;
}
repeat设置背景图片向垂直和水平方向重复
no-repeat设置背景图片不重复
repeat-x设置背景图片向水平方向重复
repeat-y设置背景图片向垂直方向重复
本文转载自中文网
声明:本文内容由网友自发贡献,本站不承担相应法律责任。对本内容有异议或投诉,请联系2913721942#qq.com核实处理,我们将尽快回复您,谢谢合作!
若转载请注明出处: background-repeat属性怎么用
本文地址: https://pptw.com/jishu/665064.html
