Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS overflow:hidden hiding a list's bullets?

I've just noticed something funny. Let's say I have a HTML list:

<ol>     <li>Lorem</li>     <li>ipsum</li>     <li>dolor</li>     <li>sit amet enim. Etiam ullamcorper. Suspendisse a pellentesque dui, non felis. Maecenas malesuada elit lectus felis, malesuada ultricies. Curabitur et ligula.</li> </ol> 

And this CSS:

li {     white-space: nowrap;     overflow: hidden; } 

The long text in the last item is indeed hacked off when it goes off the container's width, as expected. BUT! The list item numbers are affected by the overflow property too and are not shown.

However, modifying the CSS like this:

ol {     overflow: hidden; } li {     white-space: nowrap; } 

works as intended (text won't go out of the container, but list items are shown). At least all this is true for Firefox 4 beta10.

Don't you think that the numbering being affected by the overflow is a bit illogical? Why would that happen? Is it intende behaviour? Is it in the specification or is it just some oddity someone forgot to deal with?

like image 352
mingos Avatar asked Jan 30 '11 14:01

mingos


People also ask

How do you hide bullets in CSS?

Adding the "list-style: none" CSS class to the unordered list (<ul>) or ordered list (<ol>) tag removes any bullet or number.

How do you hide an overflow element?

The trick is to use flex-flow: column wrap; in conjunction with overflow: hidden; on the container. The former dictates that the content is stacked vertically and that anything that does not fit should be wrapped into a second column, outside of the content box of the container.

What CSS property would you use to remove a list item's bullets entirely?

Making CSS Remove Bullets It is possible to remove bullets from ul lists by setting the CSS list-style-type property to none . As a result, the bullets disappear from the list.


2 Answers

This is the default behavior as far as I´m aware, if the list-style-position is outside, bullets of an ul and numbers of an ol do not show. At least in Firefox, I remember seeing it before in older versions.

like image 140
jeroen Avatar answered Sep 25 '22 00:09

jeroen


Browsers add default margin and padding to lists. Try using a reset.css first to remove default styles that way you can start clean and fresh without unexpected behavior. Do a search for Eric Meyer's reset. Hope it helps.

like image 34
Jim Amos Avatar answered Sep 24 '22 00:09

Jim Amos