Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UL overlap, float:left image [duplicate]

Possible Duplicate:
Why do my list item bullets overlap floating elements

I've been having this problem with ul's next to a floating image

Here is the code i've been using

<img src="abc.jpg" width="300" height="375" style="float:left;" /> Hello world isn't this amazing
<ul>
  <li>One</li>
  <li>Two</li>
  <li>Three</li>
  <li>Four</li>
  <li>Five</li>
  <li>Six</li>
  <!--list shortened for readability-->
</ul>
<p>Extra sample text here</p>

Result

Default float problem

If it's changed to

<ul style="overflow:auto;">

Too long

The list carries on past the image, not what i want

Also trying this below gives the wrong result

<ul style="list-style-position: inside;">

Green text are comments

Photoshop of what i want What i want

like image 992
bentech Avatar asked Mar 12 '12 09:03

bentech


2 Answers

While using list-style-position: inside on the , also remove the padding-left of . The padding is usually defined by the browser. As an alternative, you could leave list-style-position: outside and increase the margin-left of until the bullets aren't overlapping.

like image 54
T. Junghans Avatar answered Nov 15 '22 05:11

T. Junghans


you can put the ul inside a div and make the div float left after the image

like image 37
kleinohad Avatar answered Nov 15 '22 03:11

kleinohad