Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > List items and margins

List items and margins
Thread Tools
Sage
Mac Elite
Join Date: Apr 2003
Location: SoCal
Status: Offline
Reply With Quote
Jan 8, 2004, 02:59 PM
 
Does the box model not apply the same way to list items as it does to other stuff?

I'm asking, because on my site, I've specified that the list items under "Results" have a 10px pixel margin all around. However, when you make the browser window smaller, and the items wrap to the next line, you'll notice that the background of the white list item overlaps with the list items below it, and I don't want that.

Here's the source code for that particular section:

Code:
<ul id="results"> <li id="winner">Mark&nbsp;&ndash;&nbsp;1'25.851</li> <li>Andrew&nbsp;&ndash;&nbsp;1'27.148</li> <li>Sage&nbsp;&ndash;&nbsp;1'28.240</li> <li>Alex&nbsp;&ndash;&nbsp;1'29.484</li> </ul>
And here are the corresponding CSS rules:

Code:
#results li { list-style: none; display: inline; margin: 10px; padding: 0; } #results li#winner { background: #fff; padding: 5px; font-weight: bold; }
     
clam2000
Dedicated MacNNer
Join Date: Aug 2002
Status: Offline
Reply With Quote
Jan 9, 2004, 01:09 AM
 
probably want to add
Code:
#results { line-height: 200%; }
(change 200 to whatever fits your needs... also can be used as em's as itn line-height: 1.5em)
...
Go O'Reilly

--will
     
Sage  (op)
Mac Elite
Join Date: Apr 2003
Location: SoCal
Status: Offline
Reply With Quote
Jan 9, 2004, 01:30 PM
 
Heh, never thought about that! And it definitely works.. thanks!

Still, just out of curiosity, is there an explanation for why margins wouldn't handle it?
     
Synotic
Mac Elite
Join Date: Oct 2000
Status: Offline
Reply With Quote
Jan 9, 2004, 04:16 PM
 
Originally posted by Sage:
Heh, never thought about that! And it definitely works.. thanks!

Still, just out of curiosity, is there an explanation for why margins wouldn't handle it?
I don't believe you can apply margins to inline elements. If you really wanted to, you could reassign your <li> elements as inline-blocks but I don't think that's as well supported.
     
redJag
Senior User
Join Date: Dec 2002
Status: Offline
Reply With Quote
Jan 9, 2004, 04:25 PM
 
Also, white-space: nowrap should work for you as well.
Travis Sanderson
     
Sage  (op)
Mac Elite
Join Date: Apr 2003
Location: SoCal
Status: Offline
Reply With Quote
Jan 10, 2004, 01:31 AM
 
Originally posted by Synotic:
I don't believe you can apply margins to inline elements.
Ah, wish someone told me that a year ago when I got started with CSS (though back then I probably didn't even know what "inline elements" meant)... thanks!

Originally posted by redJag:
Also, white-space: nowrap should work for you as well.
Well, I have about 22 other pages like that one, but some have substantially more list items, so I want to let them wrap if necessary.
     
   
 
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Top
Privacy Policy
All times are GMT -4. The time now is 08:31 PM.
All contents of these forums © 1995-2017 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.8 © 2000-2017, Jelsoft Enterprises Ltd.,