wac
10-12-2005, 08:15 PM
I'm coding up the following menu. It works fine in firefox. I know that there are issues in IE relating to the hover not working. What I'm worried about now is why the display:inline is not working on IE. I would have expected at least that to work. I know I'm missing something very simple but...
Also, is adding a 'behavior' property to introduce browser specific javascript the best way to fix IE? (yeah. I imagine I can wait until IE7)
<html>
<head>
<title>Test Stuff</title>
<style type="text/css" >
.menubar
{
padding: 4 0 4 0 ;
border-style: groove ;
}
/* fixes the box around the absolute popups
so they show in the right places */
.menubar li
{
position: relative ;
width: 100% ;
}
/* make top level ul flow left to right */
.menubar > li
{ padding: 4 ;
display: inline ;
}
.menubar > li > .menuitem
{
background-image: url(./poparrow.gif) ;
background-position: right center ;
background-repeat: no-repeat ;
}
.submenu > li > .menuitem, .popup > li > .menuitem
{
background-position: right center ;
background-image: url(./subarrow.gif) ;
background-repeat: no-repeat ;
}
.submenu, .popup
{
list-style-type: none ;
border-width: 2px ;
z-index: 10 ;
}
.menubar, .menuaction, .menuitem
{
text-decoration: none ; /* remove the underline for anchor */
padding: 4 ;
border-width: 1 ;
width: 100% ;
}
/* outset highlight on hover */
/* we use anchor to do the hover because IE
doesn't follow W3C rules to allow hover
on any component */
.menuaction:hover, .menuitem:hover
{
border-style: solid ;
}
.menubar, .submenu, .popup
{
background-color: lightgrey ;
}
/* submenus display under, popups display right */
.submenu, .popup
{
display:none ;
padding: 4 0 4 0 ;
border-style: outset ;
width: 100 ;
}
/* make popups overlap with their trigger */
.popup
{
left: 90 ;
margin: -3ex 0 0 0 ;
}
li:hover > .submenu
{
display:block ;
position: absolute ;
}
li:hover > .popup
{
display:block ;
position: absolute ;
}
</style>
</head>
<body>
<!-- the provides space for the menu arrow -->
<ul class="menubar">
<li><a href="#" class="menuitem">File </a>
<ul class="submenu" >
<li><a class="menuaction" href="#">item 1</a></li>
<li><a class="menuaction" href="#">item 2</a></li>
</ul>
</li>
<li><a href="#" class="menuaction">Test</a></li>
<li>
<a href="#" class="menuitem">Help </a>
<ul class="submenu" >
<li><a class="menuaction" href="#">About this</a></li>
<li><a class="menuitem" href="#">Contents </a>
<ul class='popup'>
<li><a class="menuaction" href="#">item 1</a></li>
<li><a class="menuaction" href="#">item 2</a></li>
<li>
<a class='menuitem' href="#">item 3 </a>
<ul class="popup" >
<li><a class="menuaction" href="#">item 1</a></li>
<li><a class="menuaction" href="#">item 2</a></li>
</ul>
</li>
</ul>
</li>
<li><a class='menuaction' href="#">item 3</a></li>
</ul>
</li>
</ul>
</span>
</body>
</html>
Also, is adding a 'behavior' property to introduce browser specific javascript the best way to fix IE? (yeah. I imagine I can wait until IE7)
<html>
<head>
<title>Test Stuff</title>
<style type="text/css" >
.menubar
{
padding: 4 0 4 0 ;
border-style: groove ;
}
/* fixes the box around the absolute popups
so they show in the right places */
.menubar li
{
position: relative ;
width: 100% ;
}
/* make top level ul flow left to right */
.menubar > li
{ padding: 4 ;
display: inline ;
}
.menubar > li > .menuitem
{
background-image: url(./poparrow.gif) ;
background-position: right center ;
background-repeat: no-repeat ;
}
.submenu > li > .menuitem, .popup > li > .menuitem
{
background-position: right center ;
background-image: url(./subarrow.gif) ;
background-repeat: no-repeat ;
}
.submenu, .popup
{
list-style-type: none ;
border-width: 2px ;
z-index: 10 ;
}
.menubar, .menuaction, .menuitem
{
text-decoration: none ; /* remove the underline for anchor */
padding: 4 ;
border-width: 1 ;
width: 100% ;
}
/* outset highlight on hover */
/* we use anchor to do the hover because IE
doesn't follow W3C rules to allow hover
on any component */
.menuaction:hover, .menuitem:hover
{
border-style: solid ;
}
.menubar, .submenu, .popup
{
background-color: lightgrey ;
}
/* submenus display under, popups display right */
.submenu, .popup
{
display:none ;
padding: 4 0 4 0 ;
border-style: outset ;
width: 100 ;
}
/* make popups overlap with their trigger */
.popup
{
left: 90 ;
margin: -3ex 0 0 0 ;
}
li:hover > .submenu
{
display:block ;
position: absolute ;
}
li:hover > .popup
{
display:block ;
position: absolute ;
}
</style>
</head>
<body>
<!-- the provides space for the menu arrow -->
<ul class="menubar">
<li><a href="#" class="menuitem">File </a>
<ul class="submenu" >
<li><a class="menuaction" href="#">item 1</a></li>
<li><a class="menuaction" href="#">item 2</a></li>
</ul>
</li>
<li><a href="#" class="menuaction">Test</a></li>
<li>
<a href="#" class="menuitem">Help </a>
<ul class="submenu" >
<li><a class="menuaction" href="#">About this</a></li>
<li><a class="menuitem" href="#">Contents </a>
<ul class='popup'>
<li><a class="menuaction" href="#">item 1</a></li>
<li><a class="menuaction" href="#">item 2</a></li>
<li>
<a class='menuitem' href="#">item 3 </a>
<ul class="popup" >
<li><a class="menuaction" href="#">item 1</a></li>
<li><a class="menuaction" href="#">item 2</a></li>
</ul>
</li>
</ul>
</li>
<li><a class='menuaction' href="#">item 3</a></li>
</ul>
</li>
</ul>
</span>
</body>
</html>