CSS里的“background-repeat:repeat”是什么意思?

html-css017

CSS里的“background-repeat:repeat”是什么意思?,第1张

在CSS中,background-repeat 属性设置是否及如何重复背景图像。

示例代码:

<html>

<head>

<meta charset="utf-8"> 

<title>示例</title>

<style>

body

{

    background-image:url('paper.gif')

    background-repeat:inherit//repeat,repeat-x,repeat-y,no-repeat

}

</style>

</head>

 

<body>

<p>inherit</p>

</body>

</html>

1、background-repeat:repeat 是默认属性,使背景图像在水平和垂直方向上重复。

2、background-repeat:repeat-x 背景图像将在水平方向重复。

3、background-repeat:repeat-y 背景图像将在垂直方向重复。

4、background-repeat:no-repeat 背景图像将仅显示一次。

5、background-repeat:inherit 规定应该从父元素继承 background-repeat      属性的设置。

这个目前的css3及以前的css规则中没有提及到。目前能够对背景进行的操作就是横向平铺(background-repeat:repeat-x)、纵向平铺(background-repeat:repeat-y)、完全平铺(background-repeat:repeat/不填写)、背景图大小(background-size)、背景定位区域(background-origin)、多重背景图片(background-image:url(bg_flower.gif),url(bg_flower_2.gif))等,还没有涉及到你说的这个重复次数的问题,你可以根据背景图的大小和想要重复的次数计算一下对应的宽高,然后限定一下宽高进行完全平铺,最后用定位将这个标签定位到你想要的位置。