CSS中怎样将背景图片平铺在CSS中,我们可以使用background属性来添加背景图像。但是,有时候我们的背景图片并不是很大,无法填充整个背景,那么我们就需要这个背景图片进行平铺。下面就是一些实现方...
CSS中怎样将背景图片平铺
在CSS中,我们可以使用background属性来添加背景图像。但是,有时候我们的背景图片并不是很大,无法填充整个背景,那么我们就需要这个背景图片进行平铺。下面就是一些实现方法。
1. repeat
使用“repeat”属性值来平铺背景图片,将图像在水平和垂直方向上平铺。
css
background-repeat: repeat; css
background-repeat: repeat-x; css
background-repeat: repeat-y; css
background-repeat: no-repeat; css
/* 设置背景图片 */
body {
background-image: url("example.jpg");
/* 平铺背景图片 */
background-repeat: repeat;
}