tags:

views:

28

answers:

2

The HTML looks like this.

<div id="leftcontainer">           
 <div id="anothercontainer">               
  <ul id="items">
   <li>Text</li> 
   <li>Text</li>
   <li>Text</li>
   <li>Text</li>
   <li>...</li>                                                                                              
  </ul>                         
 </div> 
</div> 

<div id="rightcontainer">           
 <div id="yetanothercontainer">                                  
    <ul>
   <li>Title</li>
   <li>Title</li>
   <li>Title</li>   
    </ul>
 </div>               
</div>

And the CSS looks like this.

#rightcontainer { float:right; width:40%; } 
#leftcontainer { float:left; width:60%; }
#anothercontainer { list-style: none; } 
#anothercontainer li { display:inline; }

So far so good. If there a lot of listitems in the items list, the listitems start on a new line when they almost touch the rightcontainer.

But when I add some more items to the list using jQuery, the items don't break anymore. But just keep going to the end of the page, overlapping the rightcontainer.

function success(data, textStatus) {
 $.each(data.d, function(i, item) {
  $("#items").append("<li>" + item.Name + "</li>");
 });                                 
}             
+3  A: 

Change your display type to inline-block

#anothercontainer li { display:inline-block; }
emcconville
I was going to suggest adding a space before his closing `<li>` tag...your answer is much better. +1
David Hoerster
Thanks, works great!
+1  A: 
treeface
Never tried jsFiddle. Awesome tool. Your solution works as well, but I guess the inline-block fix is cleaner.