Implement a three-level drop-down menu using pure css

Source: Internet
Author: User
Tags visibility

First View Results

 

The following is the css code.

The code is as follows: Copy code

<Style>
. Menu {
Width: 750px;
Font-size: 0.85em;
Position: relative;
Z-index: 100;
}
/* Remove all the bullets, borders and padding from the default list styling */
. Menu ul {
Padding: 0;
Margin: 0;
List-style-type: none;
}
. Menu ul {
Width: 150px;
}
/* Float the list to make it horizontal and a relative positon so that you can control the dropdown menu positon */
. Menu li {
Float: left;
Width: 150px;
Position: relative;
}
/* Style the links for the top level */
. Menu a,. menu a: visited {
Display: block;
Font-size: 11px;
Text-decoration: none;
Color: # fff;
Width: 139px;
Height: 30px;
Border: 1px solid # fff;
Border-width: 1px 1px 0 0;
Background: #758279;
Padding-left: 10px;
Line-height: 29px;
}
/* A hack so that IE5.5 faulty box model is corrected */
* Html. menu a, * html. menu a: visited {
Width: 150px;
Width: 139px;
}
 
/* Style the second level background */
. Menu ul a. drop,. menu ul a. drop: visited {
Background: # d4d8bd url (../img/drop.gif) bottom right no-repeat;
}
/* Style the second level hover */
. Menu ul a. drop: hover {
Background: # c9ba65 url (../img/drop.gif) bottom right no-repeat;
}
. Menu ul: hover> a. drop {
Background: # c9ba65 url (../img/drop.gif) bottom right no-repeat;
}
/* Style the third level background */
. Menu ul a,. menu ul a: visited {
Background: # e2dfa8;
}
/* Style the third level hover */
. Menu ul a: hover {
Background: # b2ab9b;
}
 
/* Hide the sub levels and give them a positon absolute so that they take up no room */
. Menu ul {
Visibility: hidden;
Position: absolute;
Height: 0;
Top: 31px;
Left: 0;
Width: 150px;
}
/* Another hack for IE5.5 */
* Html. menu ul {
Top: 30px;
Top: 31px;
}
 
/* Position the third level flyout menu */
. Menu ul {
Left: 150px;
Top: 0;
Width: 150px;
}
/* Position the third level flyout menu for a left flyout */
. Menu ul. left {
Left:-150px;
}
 
/* Style the table so that it takes no ppart in the layout-required for IE to work */
. Menu table {position: absolute; top: 0; left: 0 ;}
 
/* Style the second level links */
. Menu ul a,. menu ul a: visited {
Background: # d4d8bd;
Color: #000;
Height: auto;
Line-height: 1em;
Padding: 5px 10px;
Width: 129px
/* Yet another hack for IE5.5 */
}
* Html. menu ul {
Width: 150px;
Width: 129px;
}
 
/* Style the top level hover */
. Menu a: hover,. menu ul a: hover {
Color: # fff;
Background: # 949e7c;
}
. Menu: hover> a,. menu ul: hover> {
Color: # fff;
Background: # 949e7c;
}
 
/* Make the second level visible when hover on first level list OR link http://www.111cn.net */
. Menu ul li: hover ul,
. Menu ul a: hover ul {
Visibility: visible;
}
/* Keep the third level hidden when you hover on first level list OR link */
. Menu ul: hover ul {
Visibility: hidden;
}
 
/* Make the third level visible when you hover over second level list OR link */
. Menu ul: hover ul {
Visibility: visible;
}
</Style>

Html

The code is as follows: Copy code
<Div class = "menu">
 
<Ul>
<Li> <a href = "./menu/index.html"> DEMOS <! -- [If IE 7]> <! --> </A> <! -- <! [Endif] -->
<! -- [If lte IE 6]> <table> <tr> <td> <! [Endif] -->
<Ul>
<Li> <a href = "../menu/zero_dollars.html" title = "The zero dollar ads page"> zero dollars advertising page </a> </li>
<Li> <a href = "../menu/embed.html" title = "Wrapping text around images"> wrapping text around images </a> </li>
<Li> <a href = "../menu/form.html" title = "Styling forms"> styled form </a> </li>
<Li> <a href = "../menu/nodots.html" title = "Removing active/focus borders"> active focus </a> </li>
<Li> <a class = "drop" href = ".. /menu/hover_click.html "title =" Hover/click with no active/focus borders "> hover/click with no borders <! -- [If IE 7]> <! --> </A> <! -- <! [Endif] -->
<! -- [If lte IE 6]> <table> <tr> <td> <! [Endif] -->
<Ul>
<Li> <a href = "../menu/form.html" title = "Styling forms"> styled form </a> </li>
<Li> <a href = "../menu/nodots.html" title = "Removing active/focus borders"> removing active/focus borders </a> </li>
<Li> <a href = "../menu/hover_click.html" title = "Hover/click with no active/focus borders"> hover/click </a> </li>
</Ul>
<! -- [If lte IE 6]> </td> </tr> </table> </a> <! [Endif] -->
</Li>
<Li> <a class = "drop" href = "./menu/shadow_boxing.html" title = "Multi-position drop shadow"> shadow boxing <! -- [If IE 7]> <! --> </A> <! -- <! [Endif] -->
<! -- [If lte IE 6]> <table> <tr> <td> <! [Endif] -->
<Ul>
<Li> <a href = "../menu/form.html" title = "Styling forms"> styled form </a> </li>
<Li> <a href = "../menu/nodots.html" title = "Removing active/focus borders"> removing active/focus borders </a> </li>
<Li> <a href = "../menu/hover_click.html" title = "Hover/click with no active/focus borders"> hover/click </a> </li>
</Ul>
<! -- [If lte IE 6]> </td> </tr> </table> </a> <! [Endif] -->
</Li>
<Li> <a class = "drop" href = "../menu/old_master.html" title = "Image Map for detailed information"> image map for detailed information <! -- [If IE 7]> <! --> </A> <! -- <! [Endif] -->
<! -- [If lte IE 6]> <table> <tr> <td> <! [Endif] -->
<Ul>
<Li> <a href = "../menu/form.html" title = "Styling forms"> styled form </a> </li>
<Li> <a href = "../menu/nodots.html" title = "Removing active/focus borders"> removing active/focus borders </a> </li>
<Li> <a href = "../menu/hover_click.html" title = "Hover/click with no active/focus borders"> hover/click </a> </li>
</Ul>
<! -- [If lte IE 6]> </td> </tr> </table> </a> <! [Endif] -->
</Li>
<Li> <a href = "../menu/bodies.html" title = "fun with background images"> fun with background images </a> </li>
<Li> <a href = "../menu/fade_scroll.html" title = "fade-out scrolling"> fade scrolling </a> </li>
<Li> <a href = "../menu/em_images.html" title = "em size images compared"> em image sizes compared </a> </li>
</Ul>
<! -- [If lte IE 6]> </td> </tr> </table> </a> <! [Endif] -->
</Li>
<Li> <a href = "./boxes/index.html"> BOXES <! -- [If IE 7]> <! --> </A> <! -- <! [Endif] -->
<! -- [If lte IE 6]> <table> <tr> <td> <! [Endif] -->
<Ul>
<Li> <a href = "spies.html" title = "a coded list of spies"> a coded list of spies </a> </li>
<Li> <a href = "vertical.html" title = "a horizontal vertical menu"> vertical menu </a> </li>
<Li> <a href = "expand.html" title = "an enlarging unordered list"> enlarging unordered list </a> </li>
<Li> <a href = "enlarge.html" title = "an unordered list with link images"> link images </a> </li>
<Li> <a href = "cross.html" title = "non-rectangular links"> non-rectangular </a> </li>
<Li> <a href = "jigsaw.html" title = "jigsaw links"> jigsaw links </a> </li>
<Li> <a href = "circles.html" title = "circular links"> circular links </a> </li>
</Ul>
<! -- [If lte IE 6]> </td> </tr> </table> </a> <! [Endif] -->
</Li>
<Li> <a href = "./mozilla/index.html"> MOZILLA <! -- [If IE 7]> <! --> </A> <! -- <! [Endif] -->
<! -- [If lte IE 6]> <table> <tr> <td> <! [Endif] -->
<Ul>
<Li> <a href = "../mozilla/dropdown.html" title = "A drop down menu"> drop down menu </a> </li>
<Li> <a href = "../mozilla/cascade.html" title = "A cascading menu"> cascading menu </a> </li>
<Li> <a href = "../mozilla/content.html" title = "Using content:"> content: </a> </li>
<Li> <a href = "../mozilla/moxbox.html" title = ": hover applied to a div"> mozzie box </a> </li>
<Li> <a href = ".. /mozilla/rainbow.html "title =" I can build a rainbow "> I can build a rainbow with transparent borders </a> </li>
<Li> <a href = "../mozilla/snooker.html" title = "Snooker cue"> a snooker cue using border art </a> </li>
<Li> <a href = "../mozilla/target.html" title = "Target Practise"> target practice </a> </li>
<Li> <a href = "../mozilla/splittext.html" title = "Two tone headings"> two tone headings </a> </li>
<Li> <a href = "../mozilla/shadow_text.html" title = "Shadow text"> shadow text </a> </li>
</Ul>
<! -- [If lte IE 6]> </td> </tr> </table> </a> <! [Endif] -->
</Li>
<Li> <a href = "./ie/index.html"> EXPLORER <! -- [If IE 7]> <! --> </A> <! -- <! [Endif] -->
<! -- [If lte IE 6]> <table> <tr> <td> <! [Endif] -->
<Ul>
<Li> <a href = "../ie/exampleone.html" title = "Example one"> the first example for Internet Explorer </a> </li>
<Li> <a href = "../ie/weft.html" title = "Weft fonts"> weft fonts </a> </li>
<Li> <a href = "../ie/exampletwo.html" title = "Vertical align"> vertically aligning text </a> </li>
</Ul>
<! -- [If lte IE 6]> </td> </tr> </table> </a> <! [Endif] -->
</Li>
<Li> <a href = "./opacity/index.html"> OPACITY <! -- [If IE 7]> <! --> </A> <! -- <! [Endif] -->
<! -- [If lte IE 6]> <table> <tr> <td> <! [Endif] -->
<Ul>
<Li> <a href = "../opacity/colours.html" title = "color wheel"> a color wheel using opaque colours </a> </li>
<Li> <a href = "../opacity/picturemenu.html" title = "a menu using opacity"> a menu using opacity </a> </li>
<Li> <a href = "../opacity/png.html" title = "partial opacity"> partial opacity </a> </li>
<Li> <a href = "../opacity/png2.html" title = "partial opacity II"> partial opacity II </a> </li>
<Li> <a class = "drop" href = "../menu/hover_click.html" title = "Hover/click with no active/focus borders"> HOVER/CLICK <! -- [If IE 7]> <! --> </A> <! -- <! [Endif] -->
<! -- [If lte IE 6]> <table> <tr> <td> <! [Endif] -->
<Ul class = "left">
<Li> <a href = "../menu/form.html" title = "Styling forms"> styled form </a> </li>
<Li> <a href = "../menu/nodots.html" title = "Removing active/focus borders"> removing active/focus borders </a> </li>
<Li> <a href = "../menu/hover_click.html" title = "Hover/click with no active/focus borders"> hover/click </a> </li>
</Ul>
<! -- [If lte IE 6]> </td> </tr> </table> </a> <! [Endif] -->
</Li>
</Ul>
<! -- [If lte IE 6]> </td> </tr> </table> </a> <! [Endif] -->
</Li>
</Ul>
 
</Div>
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.