html - Preventing divs with images from wrapping oddly in LIs -


how may prevent odd cascading effect when using li content such following: http://jsfiddle.net/arpzt/1/

i can achieve desired behavior inserting brs after each li, a) vertical spacing between lis seem vary depending on length of content , b) there must better / more proper way of achieving this.

<ul> <li>   <div style="background-color: #990000; width:70px; float: left">       <img style="width: 45px" src="http://www.google.com/doodle4google/images/doodles/2013/1-5.jpg" />   </div>   <div style="background-color: #00ff00; margin-left: 70px;" >   body interesting large amount of content. interesting large amount of content.   </div> </li> <li>   <div style="background-color: #990000; width:70px; float: left">       <img style="width: 45px" src="http://www.google.com/doodle4google/images/doodles/2013/1-5.jpg" />   </div>   <div style="background-color: #00ff00; margin-left: 70px;" >   body interesting large amount of content. interesting large amount of content.   </div>     </li> <li>   <div style="background-color: #990000; width:70px; float: left">       <img style="width: 45px" src="http://www.google.com/doodle4google/images/doodles/2013/1-5.jpg" />   </div>   <div style="background-color: #00ff00; margin-left: 70px;" >   body interesting large amount of content. interesting large amount of content.   </div>     </li>     </ul> 

i suggest alternative clear:left suggestions, consider using overflow:hidden on li elements instead.

while clear:left fixes simple example, still have layout issues additional content following list. using overflow:hidden on li elements restrict floating effects items.

more information in this article.


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -