Reputation: 473
I have a list i want to add to a <div>
. Each listitem contains a <div>
which in turn contain an image and a text string. The list must be vertical. I ve tried putting display:block
for the <ul>
with width:100%
but the list is flowing left to right horizontally. How do I make the list vertical?
Upvotes: 47
Views: 272525
Reputation: 9146
Hope this is your structure:
<ul>
<li>
<div ><img.. /><p>text</p></div>
</li>
<li>
<div ><img.. /><p>text</p></div>
</li>
<li>
<div ><img.. /><p>text</p></div>
</li>
</ul>
By default, it will be add one after another row:
-----
-----
-----
if you want to make it vertical, just add float left to li, give width and height, make sure that content will not break the width:
| | |
| | |
li
{
display:block;
float:left;
width:300px; /* adjust */
height:150px; /* adjust */
padding: 5px; /*adjust*/
}
Upvotes: 10
Reputation: 82584
I would add this to the LI's CSS
.list-item
{
float: left;
clear: left;
}
Upvotes: 24