Forum Moderators: not2easy

Message Too Old, No Replies

Block-level links in <li>'s

Making it work in IE

         

MatthewHSE

9:19 pm on Jan 30, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If you try the following code, it will work well in Mozilla. Unfortunately, IE puts a block-level space between each <li>. Is there any way to get the proper (Mozilla) effect in IE, without resorting to putting each link in a separate table cell?

The idea is to get a side navigation bar of links, each stacked directly on top of the other, all 200px wide, with each link being set to display:block so the full 200px is clickable.

Here's the code:

<html> 

<head>

<title>Stacked Side-Nav Bar</title>

<style type="text/css">

#sidenav {background-color: #cee1f0; border: 1px solid #334dac; color: #334dac; width: 200px; position: relative;}

ul, li {margin: 0; padding: 0; list-style-type: none;}

a:link, a:visited {display: block; color: #334dac;}

a:hover, a:active {color: #ffffff; background-color: #334dac;}

</style>

</head>

<body>

<div id="sidenav">

<ul id="navbar">
<li><a href="#">Home</a></li>
<li><a href="#">My Profile</a></li>
<li><a href="#">My Membership</a></li>
<li><a href="#">Articles</a></li>
<li><a href="#">Free Newsletter</a></li>
<li><a href="#">Support</a></li>
</ul>

</div>

</body>

</html>

iamlost

5:12 am on Jan 31, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Remove the "display: block;" in the a:link, a:visited divs.

aevea

5:14 am on Jan 31, 2004 (gmt 0)

10+ Year Member



I don't really understand why ie is behaving that way but an easy fix would be to declare a height on the a element:

a {display: block; height: 1.1em; }

Adam

<edit>I was too slow...

a {display: block; width: 100%; }
works too.</edit>

dcrombie

3:50 pm on Jan 31, 2004 (gmt 0)



I had a similar issue that was fixed by removing the line breaks after the </li>'s -- really!
IE (Mac) doesn't have this problem.

isitreal

5:25 pm on Feb 5, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I just had that problem, Opera also does this, but it's resolved by removing all line breaks after </li>

<ul><li>text text</li><li>
test test</li></ul>