本文摘自PHP中文网,作者青灯夜游,侵删。
CSS的background-repeat属性是用来设置背景图像如何平铺的。background-repeat:repeat-x表示只有水平位置会重复背景图像;background-repeat:repeat-y表示只有垂直位置会重复背景图像。
CSS background-repeat属性
作用:设置是否及如何重复背景图像。
基本语法:
background-repeat:repeat|repeat-x|repeat-y|no-repeat;
repeat:默认值,背景图像将向垂直和水平方向重复。
repeat-x:只有水平位置会重复背景图像。
repeat-y:只有垂直位置会重复背景图像。
no-repeat:设置背景图片不会重复。
说明:background-repeat 属性定义了图像的平铺模式。从原图像开始重复,原图像由 background-image 定义,并根据 background-position 的值放置。
CSS background-repeat属性的使用示例
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | <!DOCTYPE html>
< html >
< head >
< meta charset = "utf-8" >
< title >菜鸟教程(runoob.com)</ title >
< style >
.demo1{
width: 400px;
height: 150px;
border: 1px solid red;
background-image:url('http://ypimg.muzhuangnet.com/Collect/csharp/upload/article/000/000/024/5c6a4428ea867709.png');
background-repeat:repeat;
}
.demo2{
width: 400px;
height: 100px;
border: 1px solid red;
background-image:url('http://ypimg.muzhuangnet.com/Collect/csharp/upload/article/000/000/024/5c6a4428ea867709.png');
background-repeat:no-repeat;
}
.demo3{
width: 400px;
height: 150px;
border: 1px solid red;
background-image:url('http://ypimg.muzhuangnet.com/Collect/csharp/upload/article/000/000/024/5c6a4428ea867709.png');
background-repeat:repeat-x;
}
.demo4{
width: 400px;
height: 400px;
border: 1px solid red;
background-image:url('http://ypimg.muzhuangnet.com/Collect/csharp/upload/article/000/000/024/5c6a4428ea867709.png');
background-repeat:repeat-y;
}
</ style >
</ head >
< body >
< h3 >repeat设置背景图片向垂直和水平方向重复</ h3 >
< div class = "demo1" ></ div >
< h3 >no-repeat设置背景图片不重复</ h3 >
< div class = "demo2" ></ div >
< h3 >repeat-x设置背景图片向水平方向重复</ h3 >
< div class = "demo3" ></ div >
< h3 >repeat-y设置背景图片向垂直方向重复</ h3 >
< div class = "demo4" ></ div >
</ body >
</ html >
|
效果图:


以上就是本篇文章的全部内容,希望能对大家的学习有所帮助。
以上就是background-repeat属性怎么用的详细内容,更多文章请关注木庄网络博客!
相关阅读 >>
详解css sroll-snap-type属性(优化滚动的小技巧)
网页不能正常显示css怎么办
css line-height值为150%或1.5值的区别
css目标伪类是什么
css中margin重叠及防止的方法介绍(代码示例)
css right属性怎么用
css的+(加号)选择器怎么用
css nav-down属性怎么用
css中auto是什么意思
css怎么设置文件编码
更多相关阅读请进入《background-repeat》频道 >>
人民邮电出版社
本书对 Vue.js 3 技术细节的分析非常可靠,对于需要深入理解 Vue.js 3 的用户会有很大的帮助。——尤雨溪,Vue.js作者
转载请注明出处:木庄网络博客 » background-repeat属性怎么用