tags:

views:

31

answers:

2

I want to repeat background image in a div but without specifying height, i want it to be flexible, if any amount of data comes in background should still be there. if i don't specify height it does not shows there but other properties like margin auto is applied.

any suggestions.

A: 
.background-element {
    background: url(tile.gif) repeat;
}

This will repeat even if the element's width/height is unknown.

Marko
nah, in my case it's not working i have a .png in background.
NativeCoder
the way i am using is overflow:auto; but when i resize my window scroll bars come in and make it ugly.
NativeCoder
define ugly?? ..
Marko
you can imagine how scroll bars inside divs will look like.
NativeCoder
Hmm.. do you need the scrollbars? Ditch the overflow:auto to get rid of them. I'm really unsure what's breaking the background, perhaps a screenshot would help?
Marko
+1  A: 

Use the property background-repeat repeat for that div tag. It should keep itself inside the div tag.

css:

.background-element {
  // just add
  background-repeat: repeat;
}

html:

<div class="background-element">
  <!-- content -->
</div>
kuroutadori
"It should keep itself inside the div tag." clarify plz
NativeCoder
When the div tag is rendered by the browser, the area that div tag creates, is where the background image should repeat.
kuroutadori