Forum Moderators: not2easy
i have the following css code for my xhtml website
#menubalk li a
{
font-family: comic sans ms,verdana,helvetica,sans-serif;
text-decoration: none;
display: block;
padding: 0.5em 0em 0.5em 1em;
color: white;
width: 90%;
background-color: #000099;
border-left: 1px solid #000098;
border-right: 1px solid #000098;
border-top: 1px solid #000098;
border-bottom: 1px solid #000098;
margin-bottom: -5px;
}
==> this is the css that i use to draw my navigation buttons in html. I want to have one panel of buttons that are drawn right under each other without additional whitespace between two buttons. With the option "margin-bottom: -5px;" it draws correctly in opera & netscape(mozilla) but not in internet explorer. if i set the bottom margin to 0px it only draws correctly in internet explorer. Does anyone have a sollution for this problem preferebly without using additional scripts or using browser specific stylesheets
Thanks anyway,
egiss
The reason it looks like you need a negative margin bottom might be to compensate for the default margin-top. Setting them both to zero makes sure that they will actually collapse to 0 cross-browser when two elements bump up against each other.
And change #menubalk li a to just #menubalk a in your style sheet.
Also, you might want to edit your post and remove the URL.
<ul>'s and <li>'s shouldn't be used for layout purposes - only as they are intended, for lists. You can easily create the same effect using padding and margins.
I would check that the XHTML is not introducing something that IE interprets as whitespace. For instance all browsers render "<ul>whatever</ul>" OK, but with IE you can get odd results with:
<ul>
whatever
</ul>
or:
<a>
whatever
</a>
<addition> One other little trick IE has which can obscure the problem, is that it can get confused between specified font sizes and inherited font sizes. If your list is in a div, then IE can render the links with the specified font size, but the line spacing from the font size inherited from the div. This can be the IE default size which is automatically inherited. If your specified font is smaller than the inherited font, then IE adds in extra vertical space. The answer is to always specify a font size to the container which is equal or less than the font size you require. I tend to use "div.class {font:1pt 'Verdana';}" which miraculously gets rid of all sorts of spacing problems.
IE is not being illogical. If you have a page of text and within it specify a few words in a smaller font, then you wouldn't want the line height to change automatically. IE is catering for this, but with unfortunate side effects. </addition>
[edited by: HarryM at 3:53 pm (utc) on Feb. 25, 2003]
unfortunately, I couldn't resolve the problem, which was similiar to your own, and had to use an unsatisfactory workaround..
ie seems to have problems with deeply contextual selectors (is that the right expression!) and margins!
one question, why do you need to use <li> at all, does the div not automatically create the breaks you want?