Adding the "list-style: none" CSS class to the unordered list (<ul>) or ordered list (<ol>) tag removes any bullet or number.
Bullet position The list-style-position property sets whether the bullets appear inside the list items, or outside them before the start of each item.
The float CSS property places an element on the left or right side of its container, allowing text and inline elements to wrap around it. The element is removed from the normal flow of the page, though still remaining a part of the flow (in contrast to absolute positioning).
I have found a solution to this problem. Applying an ul { overflow: hidden; }
to the ul
ensures that the box itself is pushed aside by the float, instead of the contents of the box.
Only IE6 needs an ul { zoom: 1; }
in our conditional comments to make sure the ul
has layout.
Adding an improvement to Glen E. Ivey's solution:
ul {
list-style: outside disc;
margin-left: 1em;
}
ul li {
position: relative;
left: 1em;
padding-right: 1em;
}
http://jsfiddle.net/mblase75/TJELt/
I prefer this technique, since it works when the list needs to flow around the floating image, while the overflow: hidden
technique will not. However, it's also necessary to add padding-right: 1em
to the li
to keep them from overflowing their container.
This is where the "display" property comes into its own. Set the CSS below to make the list work alongside the floated content.
display: table; works alongside floated content (filling the gap) but without hiding content behind it. Much like a table does :-)
.img {
float: left;
}
.table {
display: table;
}
<img class="img" src="https://via.placeholder.com/350x350" alt="">
<ul>
<li>Test content</li>
<li>Test content</li>
<li>Test content</li>
</ul>
<ul class="table">
<li>Test content</li>
<li>Test content</li>
<li>Test content</li>
</ul>
EDIT: Remember to add a class to isolate which lists you wish to do this for. E.g. "ul.in-content" or more generally ".content ul"
Try list-style-position: inside to change the layout of the bullets.
overflow: hidden
worksThe solution is as easy as:
ul {overflow: hidden;}
A block box with overflow:
other than visible
establishes a new block formatting context for its contents. W3C recommendation: http://www.w3.org/TR/CSS2/visuren.html#block-formatting
The buttons on my website, which are <li>
in disguise, are made like this. Make the viewport (window) of your browser smaller to see the indenting in action.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With