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属性的使用示例
<!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('https://img.php.cn/upload/article/000/000/024/5c6a4428ea867709.png'); background-repeat:repeat; } .demo2{ width: 400px; height: 100px; border: 1px solid red; background-image:url('https://img.php.cn/upload/article/000/000/024/5c6a4428ea867709.png'); background-repeat:no-repeat; } .demo3{ width: 400px; height: 150px; border: 1px solid red; background-image:url('https://img.php.cn/upload/article/000/000/024/5c6a4428ea867709.png'); background-repeat:repeat-x; } .demo4{ width: 400px; height: 400px; border: 1px solid red; background-image:url('https://img.php.cn/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属性怎么用的详细内容。更多信息请关注PHP中文网其他相关文章!

在本周的综述中:Firefox获得了类似锁匠的力量,三星的Galaxy Store开始支持Progressive Web Apps,CSS Subgrid正在Firefox发货

在本周的综述中:Internet Explorer进入Edge,Google Search Console吹捧新的速度报告,Firefox提供了Facebook&#039;

盖茨比(Gatsby)进行了出色的处理和处理图像。例如,它可以帮助您节省图像优化的时间,因为您不必手动


热AI工具

Undresser.AI Undress
人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover
用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool
免费脱衣服图片

Clothoff.io
AI脱衣机

AI Hentai Generator
免费生成ai无尽的。

热门文章

热工具

SecLists
SecLists是最终安全测试人员的伙伴。它是一个包含各种类型列表的集合,这些列表在安全评估过程中经常使用,都在一个地方。SecLists通过方便地提供安全测试人员可能需要的所有列表,帮助提高安全测试的效率和生产力。列表类型包括用户名、密码、URL、模糊测试有效载荷、敏感数据模式、Web shell等等。测试人员只需将此存储库拉到新的测试机上,他就可以访问到所需的每种类型的列表。

ZendStudio 13.5.1 Mac
功能强大的PHP集成开发环境

Atom编辑器mac版下载
最流行的的开源编辑器

PhpStorm Mac 版本
最新(2018.2.1 )专业的PHP集成开发工具

SublimeText3 Mac版
神级代码编辑软件(SublimeText3)