简体   繁体   English

后台重复不起作用

[英]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. 检查以下内容以获取背景重复属性的完整列表。

Link for CSS Background-repeat CSS重复背景链接

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;
}

http://jsfiddle.net/Hvqww/ http://jsfiddle.net/Hvqww/

If you change to 如果您更改为

background-repeat:repeat; 

it's working fine, even if the height increases: 即使高度增加,它也能正常工作:

JSFiddle 的jsfiddle

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM