[英]background-repeat is not working
I have one div : 我有一个div:
fiddle for my problem. 摆弄我的问题。
HTML : HTML:
<div class="listinggitems">
</div>
CSS : CSS:
.listinggitems
{
min-height:280px;
width:785px;
background: url(images/bgdoodle.png);
background-repeat:repeat-xy;
position:relative;
margin-left:210px;
margin-top:20px;
}
Upto 280px
height, background display but when div size automatically increase as data in it increase the background image doesn't increase. 280px
,背景显示,但当div大小随数据增加而自动增加时,背景图片不会增加。 I also tried background-repeat:repeat-xy;
我也尝试了
background-repeat:repeat-xy;
but it also display background upto 280px
after that it doesn't display it. 但在不显示背景
280px
,它也显示高达280px
像素的背景。 when manually I increase height of div
then background increase. 当我手动增加
div
高度,然后背景增加。 I have to load dynamic data into that div
so I have to use min-height
. 我必须将动态数据加载到该
div
所以必须使用min-height
。
Any suggestion ??? 有什么建议吗?
in your HTML ammend last 3 line's to : 在您的HTML中将最后3行改为:
</div>
<div class="clr"></div>
</div>
in CSS add : 在CSS中添加:
.clr{clear:both}
Why its happening?? 为什么会发生?? You are setting the
child-divs
to float which means that the container div (listinggitems)
cannot work out it's actual height. 您将
child-divs
设置为float,这意味着容器div (listinggitems)
无法计算出其实际高度。 You need to clear the floated element which essentially lets the container know how large the image actualy is. 您需要清除float元素,这实际上使容器知道实际的图像大小。
That's why u'll need to add an element with the style clear: both;
这就是为什么您需要添加一个样式
clear: both;
的元素clear: both;
Your background-repeat
property declaration ie background-repeat:repeat-xy;
您的
background-repeat
属性声明,即background-repeat:repeat-xy;
is incorrect. 是不正确的。
Either use background-repeat:repeat-x;
请使用
background-repeat:repeat-x;
or background-repeat:repeat-y;
或
background-repeat:repeat-y;
or background-repeat:repeat;
或
background-repeat:repeat;
to repeat. 重复。
Check the below for a complete list of Background repeat attributes. 检查以下内容以获取背景重复属性的完整列表。
try this one, 试试这个
.listinggitems
{
min-height:280px;
width:785px;
background-image:url(images/bgdoodle.png);
background-repeat:repeat;
position:relative;
margin-left:210px;
margin-top:20px;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.