Fu E Luo

Navigation

Skip navigation.

Search

Site navigation

Email conversation

FromFu E Luo
ToMe
SubjectProblem with Pure CSS menus
Date9 August 2004 22:17
Hi,
 
First off, I just want to say that your tutorial was just what I was
looking for. Creating a menu with CSS and not JavaScript.
 
The example code you've shown on your site begins something like this:
<ul class="makeMenu">
     <li>>> Lips
          <ul>
         </ul>
....and it goes on.
 
I had a problem when I made one minor change. The new code looks like this:
<ul class="makeMenu">
     <li><a href="lips.html">>> Lips</a>
          <ul>
               ...
         </ul>
.....
I wanted the top menu block ('Lips' in this case) to also be a link. But
the result wasn't good. Moving the mouse pointer from 'Lips' to the submenu
'Cat' changed the font color of 'Lips' to be something unreadable.
 
Hope you can help. Thanks,
Fu Luo
FromMe
ToFu E Luo
SubjectRe: Problem with Pure CSS menus
Date11 August 2004 08:35
Fu,

you need to incluse an extra couple of lines of CSS to say that child links
of a hovered LI must also be coloured, even if the links themselves are not
being coloured

however, you also need to counterract that so that child links of a child
LI of a hovered LI are not coloured, unless they themselves are hovered
(hay, no-one said this was easy)

for good browsers that understand the > selector (not IE on windows ...),
this is very easy

/* extra selectors for extra specificity - just in case */
ul.makeMenu li:hover > a { color: 000; }

but for IE/windows, the two 'for' loops in the .htt file need to be changed
to add the extra functionality
...
for( var x = 0; element.childNodes[x]; x++ ){
 if( element.childNodes[x].tagName == 'UL' ) { element.childNodes[x].style.display = 'block'; }
 if( element.childNodes[x].tagName == 'A' ) { element.childNodes[x].style.color = '#000'; }
}
...
for( var x = 0; element.childNodes[x]; x++ ){
 if( element.childNodes[x].tagName == 'UL' ) { element.childNodes[x].style.display = 'none'; }
 if( element.childNodes[x].tagName == 'A' ) { element.childNodes[x].style.color = '#fff'; }
}
...

with any luck, that should work

Mark 'Tarquin' Wilton-Jones - author of http://www.howtocreate.co.uk/
This site was created by Mark "Tarquin" Wilton-Jones.
Don't click this link unless you want to be banned from our site.