Forum Moderators: not2easy
The latest problem:
I wanted to create a list of divs using the "ul li"-technique, but I can't seem to get it right. The result should be a horizontal list of divs with automatic line-breaks depending on page width.
I can't use float:left since my divs in real-life are different height, so sometimes they stack up on each other.
If I use <span> or <a href> it works, but the divs positions vertical instead of inline.
Here's a simplified example...
css:
#gallery ul{
margin:0px;
padding:0px;
list-style:none;
}
#gallery li{
display:inline;
}
.myDiv{
width:150px;
height:100px;
}
HTML (using doctype XHTML 1.1):
<div id="gallery">
<ul>
<li><div class="myDiv">hello1</div></li>
<li><div class="myDiv">hello2</div></li>
<li><div class="myDiv">hello3</div></li>
<li><div class="myDiv">hello4</div></li>
</ul>
</div>
Thanks alot for your help!
/Martin
You need float your divs. The alternative would be to float the li (instead of dipsly inline). If your li where still blocks, they would contain the div to the appropriate size, and they wouldn't break the flow.
I don't know it this other option would work, but maybe setting a with to the li, while still inline.
I solved it (kind of) by using some vbscript to insert clear:all between each row (I'm using a fixed width of the page anyway).
But it's a pity I didn't get it right with the original idea, it had been so much cleaner...