这篇文章给大家介绍html怎么设置背景图片平铺方,内容非常详细,感兴趣的小伙伴们可以参考借鉴,希望对大家能有所帮助。
html背景图片设置平铺方式
<!DOCTYPE html>
<html>
<head>
<style type="text/css">
div{
border: 1px solid #000fff;
height: 200px;
background-image: url(img/1.jpg);
margin-bottom:10px ;
}
#content1 {
background-repeat: repeat;
}
#content2 {
background-repeat: repeat-x;
}
#content3 {
background-repeat: repeat-y;
}
#content4 {
background-repeat: no-repeat;
}
</style>
</head>
<body>
<div id="content1"></div>
<div id="content2"></div>
<div id="content3"></div>
<div id="content4"></div>
</body>
</html>
效果图:

说明:
background-repeat 属性设置是否及如何重复背景图像,定义了图像的平铺模式。
默认地,背景图像在水平和垂直方向上重复。
属性值:
值 | 描述 |
---|
repeat | 默认。背景图像将在垂直方向和水平方向重复。 |
repeat-x | 背景图像将在水平方向重复。 |
repeat-y | 背景图像将在垂直方向重复。 |
no-repeat | 背景图像将仅显示一次。 |
关于html怎么设置背景图片平铺方就分享到这里了,希望以上内容可以对大家有一定的帮助,可以学到更多知识。如果觉得文章不错,可以把它分享出去让更多的人看到。