>> <span class="here">Chapter 2
>> <ul>
>
> FYI, that's invalid. <span> can only contain other inline elements.
drat! ... this works in my IE6, FF2, didn't check IE7 maybe someone here
can:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Test for IE gaps</title>
<style type="text/css">
body:{
margin: 0;
padding: 10px;
}
#navigation {
width:12em;
}
#navigation ul {
list-style-position:outside;
list-style-type:none;
margin:0;
padding:0;
}
#navigation li {
margin:0;
padding:0;
}
#navigation a,
#navigation span {
display:block;
}
/* Level 1 */
#navigation ul li a,
#navigation ul li span {
padding:0.2em 0.2em 0.2em 1em;
background-color:#cccccc;
}
.here{
background-color:#999999;
padding:0.2em 0.2em 0.2em 1em;
}
#navigation ul li a:hover,
#navigation ul li a:focus,
#navigation ul li a:active{
background-color:#999999;
}
/* Level 2 positioned absolute */
#navigation ul li {
position:relative;
}
#navigation ul li ul {
position:absolute;
top:0;
left:12em;
width:12em;
z-index:6;
display:block;
}
#navigation ul li ul li a, #navigation ul li ul li span {
background-color:#ffff00;
}
#navigation ul li ul li a:hover, #navigation ul li ul li a:focus,
#navigation ul li ul li a:active, #navigation ul li ul li a.here,
#navigation ul li ul li span.here {
background-color:#cccc00;
}
</style>
<!--[if lt IE 7]>
<style type="text/css">
/* fix gaps for IE 6- by giving elements "hasLayout" property */
#navigation ul,
#navigation li,
#navigation a,
#navigation span {
height:1px;
}
</style>
<![endif]-->
</head>
<body>
<div id="navigation">
<ul>
<li><a href="#">Chapter 1</a></li>
<li>
<div class='here'>
Chapter 2
<ul>
<li><span class="here">Chapter 2.3.1</span></li>
<li><a href="#">Chapter 2.3.2</a></li>
</ul>
</div>
</li>
<li><a href="#">Chapter 3</a></li>
<li><a href="#">Chapter 4</a></li>
</ul>
</div>
</body>
</html>
Markus - 30 May 2007 10:15 GMT
Mike Scirocco schrieb:
>>> <span class="here">Chapter 2
>>> <ul>
[quoted text clipped - 3 lines]
> drat! ... this works in my IE6, FF2, didn't check IE7 maybe someone here
> can:
[code snipped]
> <li>
> <div class='here'>
[quoted text clipped - 5 lines]
> </div>
> </li>
The problem here is that the <span> element can also be an <a> element,
so replacing it by a <div> is only applicable for the menu point of the
page shown. I see that this was not made clear in my example.
Your suggestion also shows that HTML specs in some points are in
conflict with things that would be desirable in combination with CSS:
<li>
<a href="chapter-2.html">Chapter 2
<ul>
<li><a href="chapter-21.html">Chapter 2.1</a></li>
<li><a a href="chapter-22.html">Chapter 2.2</a></li>
</ul>
</a>
</li>
This is not valid, though it would make mouseover effects much easier
without the need of scripting:
a ul {
display:none;
}
a:hover ul, a:focus ul, a:active ul {
display:block;
}
I don't actually know whether li:hover would be valid; it would not be
widely supported anyway.