Forum Moderators: not2easy
<div id= "wrapper">
<div id= "siteNavigation">
<ul><li><a href="#" class="active">Home</a></li>
<li><a href="#">Team</a>
<ul>
<li><a href="#">Lucy</a></li>
<li><a href="#">Hannah</a></li>
<li><a href="#">Phil</a></li>
<li><a href="#">Claire</a></li>
<li><a href="#">Carly</a></li>
<li><a href="#">James</a></li>
<ul>
<li> <a href="#">image/details</a></li> <!-- I want this to be a picture when once clicked takes you to a URL -->
</ul> <!-- end james pic -->
</ul> <!--end inner ul-->
<li><a href="#">Trainees</a></li>
</ul> <! End Ul-->
</li> <!-- End li main-->
</ul>
</div> <!--siteNavigationend-->
</div> <!-- wrapper end-->
</body>
</html>
}
#siteNavigation ul ul { /**this is the thing I used to hide the drop down menu**/
position:absolute;
visibility:hidden;
top:32px;
}
#siteNavigation ul li:hover ul { /**this is the thing I used to show it with a hover**/
visibility:visible;
} <div id= "siteNavigation">
<ul>
<li><a href="#" class="active">Home</a></li>
<li><a href="#">Team</a>
<ul>
<li><a href="#" class="name">Lucy</a> <a href="#" class="img"><img src="lucy.jpg" alt="Lucy"></a></li>
<li><a href="#" class="name">Hannah</a></li>
<li><a href="#" class="name">Phil</a></li>
<li><a href="#" class="name">Claire</a> </li>
<li><a href="#" class="name">Carly</a> <a href="#" class="img"><img src="Carly.jpg" alt="Carly"></a></li>
<li><a href="#" class="name">James</a> <a href="#" class="img"><img src="James.jpg" alt="James"></a></li>
</ul> <!--end inner ul-->
</li> <!-- end team LI -->
<li><a href="#">Trainees</a></li>
</ul><!-- End main UL -->
</div> <!--siteNavigationend-->
#siteNavigation ul ul { /**this is the thing I used to hide the drop down menu**/
position:absolute;
visibility:hidden;
top:32px;
}
#siteNavigation ul ul li {/* so the absolute img takes position fromm it */
position: relative;
}
#siteNavigation ul ul a.name {
display: block;
background: #dad;
width: 100px;
height: 28px;
border: 1px solid #000;
border-width: 1px 0;
line-height: 30px
}
#siteNavigation ul ul a.name:hover {
background: #eee;
}
#siteNavigation ul ul a.img {
visibility:hidden; /* hide the image until name is hovered on */
position: absolute;
left: 100px;
top: 0;
background: #eee;
width: 100px;
height: 100px;
}
#siteNavigation ul li:hover ul,
#siteNavigation ul ul li:hover a.img { /* first one shows drop down list, second one shows hidden image link when name is hovered on */
visibility:visible;
}
<li><a href="#">Handouts</a>
<ul>
<li><a href="#" class="name">Basics</a> </li>
<ul>
<li><a href="#" class="name"> Keyboard </a></li>
</ul> ul li:hover ul rules and their subsequent "negation" rules for show/hide child levels for however many levels you want.. #whateverid ul {} is just the way of uniquely identifying that particular set of lists, as opposed to other lists that might exist on the page.. it saves you putting multiple class names on individual lists.. by lists here I mean <ul> elements #menu ul{} is targeting a <ul> element which has an ancestor (not necessarily a direct parent) with an id of "menu" - because other lists in your page don't have a parent/ancestor with that id they are not included in your target styles, that's what is meant by specificity in CSS and is how you isolate specific areas/divs of your page like menus, sidebars etc. now when it comes to reading the tutorial CSS code it might be helpful to remember that, an ID is the all conquering hero when it comes to specifity nothing can usurp it even order of the Cascade, i.e. the order things are written in the stylesheets.. which is why that bit (#menu) even exists but then the next way to add specificity to selectors is to add more elements <div id="sitenav">
<ul class="toplevel">
<li><a href="#">Calendar</a></li>
<li><a href="#">Handouts >></a>
<ul><!-- level 2 -->
<li><a href="#">Basics >></a>
<ul><!-- level 3 -->
<li><a href="#">Keyboard</a></li>
<li><a href="#">level 3.2</a></li>
<li><a href="#">level 3.3 >></a>
<ul><!-- level 4 -->
<li><a href="#">level 4.1</a></li>
<li><a href="#">level 4.2</a></li>
<li><a href="#">level 4.3</a></li>
</ul><!-- //level 4 -->
</li><!-- list item 3.3-->
</ul><!-- //level 3 -->
</li><!-- basics -->
<li><a href="#">Word</a></li>
<li><a href="#">Excel</a></li>
<li><a href="#">Ancestry</a></li>
<li><a href="#">Crafts</a></li>
<li><a href="#">Internet</a></li>
</ul><!--//level 2-->
</li><!--//handouts-->
<li><a href="#" >News</a></li>
<li><a href="#" >Affiliates</a></li>
</ul><!--//top level-->
</div>
#sitenav ul {} - will select any <ul> that is a descendant of the #sitenav div, which is every ul in the menu above #sitenav>ul {} (or #sitenav > ul {}, whitespace is optional) - will only select a <ul> which is a child of the #sitenav div, which in this case is the "toplevel" <ul>
/* wrapper div for the dropdown lists */
#sitenav {
width: 80%;
margin: 0 auto; /* will center the whole navigation if the width is less than 100% */
font-family: "trebuchet ms", georgia, sans-serif;
font-size: 18px;
font-weight: bold;
}
/* starting all the child properties inside this wrapper with #sitenav will mean the rules only apply to this menu */
#sitenav ul {
margin: 0; padding: 0; list-style: none; /* zero all the list defaults in the sitenav wrapper div */
background: #fff;
color: #000;
border-width: 0; /* border width set on each list as required */
border-style: solid;
border-color: #f00; /* red */
}
/* make the top-level list horizontal */
#sitenav > ul {
float: left;
width: 100%;
border-width: 1px 0; /* top and bottom border only on the horizontal top bit */
}
/* without the child selector this targets all other levels of list, 2 or more deep */
#sitenav ul ul {
border-width: 1px 1px 0 1px; /* 0 bottom border, the bottom one comes from the li items */
}
/* float the top level li items so they sit side by side, you can give them a height here too if you like */
#sitenav > ul > li {
float: left;
width: 130px;
position: relative; /* so the droplists, the children of li's, have something to take their position from */
text-align: center;
height: auto; /*if you do give them a px height you would need to adjust the top co-ordinate of it's child menu - I've noted below where */
}
/* no child selector so this targets all list items 2 levels and more deep */
#sitenav li li {
float: left;
width: 130px;
text-align: left;
border-width: 0 0 1px 0; /* bottom border only */
border-style: solid;
border-color: #f00; /* red */
}
/** links ***/
#sitenav li a {
display: block;
background: #fff;
color: #000;
text-decoration: none;
padding: 0 10px;
}
#sitenav li a:hover {
background: #f00;
color: #fff;
}
/** everything after this now does the positioning of the child lists **/
/* position _all_ the second level and greater lists */
#sitenav ul ul {
position: absolute;
}
/* positioning co-ordinates for the second level (1st) drop
this actually targets all levels but is overruled in the rule which follows */
#sitenav ul ul {
top: auto; /* this is default and could be left out, it's in here for clarity because you would use a px value here to match the height of the top li's if you've used one */
left: 0;
}
/* positioning co-ordinates of all further level's (3rd, 4th etc) drops so they appear to the right of the 1st drop */
#sitenav ul ul ul {
top: 0;
left: 100%;
margin-top: -1px; /* to compensate for top border */
}
is it going to complicate things when the team drops down and when name hovered over gives an image? as in will it effect this bit at all?
/* hide all child lists */
#sitenav ul ul {visibility: hidden;}
/* IE7 hack - IE7 likes a :hover rule before using :hover in other rules! */
#sitenav li:hover {zoom: 1;}
/* unhide CHILD level on hover of a list item */
#sitenav li:hover > ul {visibility: visible;}
/* keep those links looking like they're active when their descendants are visible */
#sitenav li:hover > a {
background: #f00;
color: #fff;
}
(affiliates I want to drop down but have the affiliates as horizontal)
<li><a href="#" >News</a></li>
.... above already there
<li><a href="#">Team</a>
<ul id="navteam">
<li><a href="#" class="name">Lucy</a> <a href="#" class="img"><img src="lucy.jpg" alt="Lucy"></a></li>
<li><a href="#" class="name">Hannah</a></li>
<li><a href="#" class="name">Phil</a></li>
<li><a href="#" class="name">Claire</a> </li>
<li><a href="#" class="name">Carly</a> <a href="#" class="img"><img src="Carly.jpg" alt="Carly"></a></li>
<li><a href="#" class="name">James</a> <a href="#" class="img"><img src="James.jpg" alt="James"></a></li>
</ul> <!--//navteam-->
</li> <!-- //team LI -->
...... below already there
<li><a href="#" >Affiliates</a></li>
/** the Team nav menu bit **/
/* It's a second level list, and the 3rd level is not realy a level but instead just a popout image */
/* this is code that isolates it */
#sitenav ul#navteam {}
#sitenav #navteam li {position: relative;}
#sitenav #navteam img {display: block;}
#sitenav #navteam a.img {
visibility:hidden; /* hide the image until name is hovered on */
position: absolute;
left: 100%;
top: 0;
background: #eee;
width: 100px;
height: 100px;
}
#sitenav #navteam li:hover a.img {
visibility: visible; /* shows the hidden image link when name class is hovered on */
}
#sitenav li:hover {position: relative;} #sitenav ul {} rules to keep with the logical flow, it's inherited by all <li> items and is not then need in the other places /*#sitenav li:hover {zoom: 1;}*/ #sitenav #navteam li {position: relative;}