Three CSS implementation drop-down menus

Source: Internet
Author: User
Three CSS implementation drop-down menus

One ....................................

HTML code:
<HTML xmlns = "http://www.w3.org/1999/xhtml" XML: lang = "en">
<Head>
<Meta http-equiv = "Content-Type" content = "application/XHTML + XML; charset = UTF-8"/>
<Title> drop down menu </title>
<Style type = "text/CSS">
Body {font-size: 1%; color: # FFF;}/* Get Rid Of the IE bug that prints the end Of! Doctype */
. Menu {display: none ;}
. Holder {color: #000; width: 90px; Height: 18px; display: block; Background: # DCA; Border: 1px solid #000; margin-Right: 1px; text-align: center; float: Left; text-Decoration: none; font-family: tahoma, Vardana, Arial, sans-serif; font-size: 10px; line-height: 18px; overflow: hidden ;}
. Holder: hover {Height: auto; cursor: pointer; color: # FFF; Background: #000 ;}
A. inner,. inner: visited {display: block; width: 89px; Height: 18px; border-bottom: 1px solid #000; text-Decoration: none; color: #000; Background: # Eee ;}
A. Inner: hover {Background: # Add ;}
P {color: #000; font-size: 16px ;}
</Style>

<! -- [If IE]>
<Style type = "text/CSS">
/* <! [CDATA [*/
. Holder {display: none ;}
. Menu {display: block ;}
A. outer,. outer: visited {color: #000; width: 90px; Height: 18px; display: block; Background: # DCA; Border: 1px solid #000; margin-Right: 1px; text-align: center; float: Left; text-Decoration: none; font-family: tahoma, Vardana, Arial, sans-serif; font-size: 10px; line-height: 18px; overflow: hidden ;}
A. Outer: hover {color: # FFF; Background: #000; overflow: visible ;}
A. Outer: hover table {display: block; Background: # Eee; border-collapse: collapse ;}
A. inner,. inner: visited {display: block; width: 88px; Height: 18px; border-bottom: 1px solid #000; text-Decoration: none; color: #000; font-family: tahoma, Vardana, Arial, sans-serif; font-size: 10px; text-align: center ;}
A. Inner: hover {Background: # Add ;}
/*]> */
</Style>
<! [Endif] -->

</Head>

<Body>
<P> for another demo with page content see <a href = "http://www.stunicholls.myby.co.uk/menus/drop_down.html" Title = "another Demo"> This page </a>

<Div class = "menu">
<A class = "outer" href = "page1.html"> menu 1
<Table> <tr> <TD>
<A class = "inner" href = "page1a.html"> page 1A </a>
<A class = "inner" href = "page1b.html"> page 1B </a>
<A class = "inner" href = "page1c.html"> page 1C </a>
<A class = "inner" href = "page1d.html"> page 1D </a>
<A class = "inner" href = "page1e.html"> page 1E </a>
</TD> </tr> </table>
</A>

<A class = "outer" href = "page1.html"> menu 2
<Table> <tr> <TD>
<A class = "inner" href = "page2a.html"> page 2a </a>
<A class = "inner" href = "page2b.html"> page 2B </a>
<A class = "inner" href = "page2c.html"> page 2C </a>
<A class = "inner" href = "page2d.html"> page 2D </a>
</TD> </tr> </table>
</A>
</Div>

<Div class = "Holder">
Menu 1 <br/>
<A class = "inner" href = "page1a.html"> page 1A </a>
<A class = "inner" href = "page1b.html"> page 1B </a>
<A class = "inner" href = "page1c.html"> page 1C </a>
<A class = "inner" href = "page1d.html"> page 1D </a>
<A class = "inner" href = "page1e.html"> page 1E </a>
</Div>
<Div class = "Holder">
Menu 2 <br/>
<A class = "inner" href = "page2a.html"> page 2a </a>
<A class = "inner" href = "page2b.html"> page 2B </a>
<A class = "inner" href = "page2c.html"> page 2C </a>
<A class = "inner" href = "page2d.html"> page 2D </a>
</Div>
</Body>
</Html>

 

 

Two ....................................

HTML code:
<HTML xmlns = "http://www.w3.org/1999/xhtml" lang = "ZH-CN">
<Head>
<Meta http-equiv = "Content-Type" content = "text/html; charset = gb2312"/>
<Title> CSS menu demonstration </title>

<Style type = "text/CSS">
<! --

* {Margin: 0; padding: 0; Border: 0 ;}
Body {
Font-family: Arial,, Serif;
Font-size: 12px;
}

# Nav {
Line-Height: 24px; List-style-type: none; Background: #666;
}

# Nav {
Display: block; width: 80px; text-align: center;
}

# Nav A: link {
Color: #666; text-Decoration: none;
}
# Nav A: visited {
Color: #666; text-Decoration: none;
}
# Nav A: hover {
Color: # FFF; text-Decoration: none; font-weight: bold;
}

# Nav Li {
Float: Left; width: 80px; Background: # CCC;
}
# Nav Li A: hover {
Background: #999;
}
# Nav Li ul {
Line-Height: 27px; List-style-type: none; text-align: left;
Left:-999em; width: 180px; position: absolute;
}
# Nav Li ul Li {
Float: Left; width: 180px;
Background: # f6f6f6;
}

# Nav Li ul {
Display: block; width: 156px; text-align: Left; padding-left: 24px;
}

# Nav Li ul a: link {
Color: #666; text-Decoration: none;
}
# Nav Li ul a: visited {
Color: #666; text-Decoration: none;
}
# Nav Li ul a: hover {
Color: # f3f3f3; text-Decoration: none; font-weight: normal;
Background: # c00;
}

# Nav Li: hover ul {
Left: auto;
}
# Nav Li. sfhover ul {
Left: auto;
}
# Content {
Clear: left;
}

-->
</Style>

<SCRIPT type = text/JavaScript> <! -- // --> <! [CDATA [//> <! --
Function menufix (){
VaR sfels = Document. getelementbyid ("nav"). getelementsbytagname ("Li ");
For (VAR I = 0; I <sfels. length; I ++ ){
Sfels [I]. onmouseover = function (){
This. classname + = (this. classname. length> 0? "": "") + "Sfhover ";
}
Sfels [I]. onmousedown = function (){
This. classname + = (this. classname. length> 0? "": "") + "Sfhover ";
}
Sfels [I]. onmouseup = function (){
This. classname + = (this. classname. length> 0? "": "") + "Sfhover ";
}
Sfels [I]. onmouseout = function (){
This. classname = This. classname. Replace (New Regexp ("(? | ^) Sfhover // B "),

"");
}
}
}
Window. onload = menufix;

// --> <!]> </SCRIPT>

</Head>
<Body>

<Ul id = "nav">
<Li> <a href = "#"> product introduction </a>
<Ul>
<Li> <a href = "#"> product 1 </a> </LI>
<Li> <a href = "#"> product 1 </a> </LI>
<Li> <a href = "#"> product 1 </a> </LI>
<Li> <a href = "#"> product 1 </a> </LI>
<Li> <a href = "#"> product 1 </a> </LI>
<Li> <a href = "#"> product 1 </a> </LI>
</Ul>
</LI>
<Li> <a href = "#"> service Introduction </a>
<Ul>
<Li> <a href = "#"> Service 2 </a> </LI>
<Li> <a href = "#"> Service 2 </a> </LI>
<Li> <a href = "#"> Service 2 </a> </LI>
<Li> <a href = "#"> Service 2 Service 2 </a> </LI>
<Li> <a href = "#"> Service 2 Service 2 </a> </LI>
<Li> <a href = "#"> Service 2 </a> </LI>
</Ul>
</LI>
<Li> <a href = "#"> success stories </a>
<Ul>
<Li> <a href = "#"> case 3 </a> </LI>
<Li> <a href = "#"> case </a> </LI>
<Li> <a href = "#"> case 3 case 3 </a> </LI>
<Li> <a href = "#"> case 3 case 3 case 3 </a> </LI>
</Ul>
</LI>
<Li> <a href = "#"> about us </a>
<Ul>
<Li> <a href = "#"> ours 4 </a> </LI>
<Li> <a href = "#"> ours 4 </a> </LI>
<Li> <a href = "#"> ours 4 </a> </LI>
<Li> <a href = "#"> 4. 111 </a> </LI>
</Ul>
</LI>

<Li> <a href = "#"> online demonstration </a>
<Ul>
<Li> <a href = "#"> demo </a> </LI>
<Li> <a href = "#"> demo </a> </LI>
<Li> <a href = "#"> demo </a> </LI>
<Li> <a href = "#"> demo </a> </LI>
<Li> <a href = "#"> demo </a> </LI>
<Li> <a href = "#"> demo </a> </LI>
<Li> <a href = "#"> demo </a> </LI>
<Li> <a href = "#"> demo </a> </LI>
</Ul>
</LI>
<Li> <a href = "#"> Contact Us </a>
<Ul>
<Li> <a href = "#"> Contact Us </a> </LI>
<Li> <a href = "#"> contact </a> </LI>
<Li> <a href = "#"> contact </a> </LI>
<Li> <a href = "#"> contact </a> </LI>
<Li> <a href = "#"> contact </a> </LI>
<Li> <a href = "#"> contact </a> </LI>
<Li> <a href = "#"> contact </a> </LI>
</Ul>
</LI>

</Ul>

</Body>
</Html>

 

Three .....................

HTML code:
<HTML xmlns = "http://www.w3.org/1999/xhtml" lang = "ZH-CN">
<Head>
<Meta http-equiv = "Content-Type" content = "text/html; charset = gb2312"/>
<Meta http-equiv = "content-language" content = "ZH-CN"/>
<Title> horizontal drop-down menu </title>
<Style type = "text/CSS">
<! --
* {Margin: 0; padding: 0; Border: 0 ;}

Body {
Font-family: Arial,, Serif;
Font-size: 12px;
}

# Nav {
Height: 24px; List-style-type: none; padding-left: 200px;

Line-Height: 24px; overflow: hidden; Background: #999;
}

# Nav {
Display: block; width: 80px; text-align: center;
}

# Nav A: link {
Color: # Eee; text-Decoration: none;
}
# Nav A: visited {
Color: # Eee; text-Decoration: none;
}
# Nav A: hover {
Color: # FFF; text-Decoration: none; font-weight: bold; Background: # CCC;
}

# Nav Li {
Float: Left; width: 80px;
}

# Nav Li ul {
Line-Height: 24px;
List-style-type: none;
Text-align: left;
Left:-999px;
Width: 520px; // note that the width must be set here;
Position: absolute;
Background: # CCC;
}

# Nav Li ul Li {
Float: Left; width: 80px; // float is the key to the horizontal sub-menu. It can inherit the parent menu and omit float.
}

# Nav Li ul {
Display: block; width: 65px; text-align: Left; padding-left: 15px;
}

# Nav Li ul a: link {
Color: # f1f1f1; text-Decoration: none;
}
# Nav Li ul a: visited {
Color: # f1f1f1; text-Decoration: none;
}
# Nav Li ul a: hover {
Color: # FFF; text-Decoration: none; font-weight: normal; Background: # c00;
}

# Nav Li: hover ul {
Left: 25%;
}

# Nav Li. sfhover ul {
Left: 25%;
}

# Content {
Clear: left;
}

-->
</Style>

<SCRIPT type = text/JavaScript> <! -- // --> <! [CDATA [//> <! --
Function menufix (){
VaR sfels = Document. getelementbyid ("nav"). getelementsbytagname ("Li ");
For (VAR I = 0; I <sfels. length; I ++ ){
Sfels [I]. onmouseover = function (){
This. classname + = (this. classname. length> 0? "": "") + "Sfhover ";
}
Sfels [I]. onmousedown = function (){
This. classname + = (this. classname. length> 0? "": "") + "Sfhover ";
}
Sfels [I]. onmouseup = function (){
This. classname + = (this. classname. length> 0? "": "") + "Sfhover ";
}
Sfels [I]. onmouseout = function (){
This. classname = This. classname. Replace (New Regexp ("(? | ^) Sfhover // B "),

"");
}
}
}
Window. onload = menufix;

// --> <!]> </SCRIPT>
</Head>
<Body>

<Ul id = "nav">
<Li> <a href = "#"> menu 1 </a>
<Ul>
<Li> <a href = "#"> menu 1 </a> </LI>
<Li> <a href = "#"> menu 1 </a> </LI>
<Li> <a href = "#"> menu 1 </a> </LI>
<Li> <a href = "#"> menu 1 </a> </LI>
<Li> <a href = "#"> menu 1 </a> </LI>
<Li> <a href = "#"> menu 1 </a> </LI>
</Ul>
</LI>
<Li> <a href = "#"> menu 2 </a>
<Ul>
<Li> <a href = "#"> menu 2 </a> </LI>
<Li> <a href = "#"> menu 2 </a> </LI>
<Li> <a href = "#"> menu 2 </a> </LI>
<Li> <a href = "#"> menu 2 </a> </LI>
<Li> <a href = "#"> menu 2 </a> </LI>
</Ul>
</LI>
<Li> <a href = "#"> menu 3 </a>
<Ul>
<Li> <a href = "#"> menu 3 </a> </LI>
<Li> <a href = "#"> menu 3 </a> </LI>
<Li> <a href = "#"> menu 3 </a> </LI>
<Li> <a href = "#"> menu 3 </a> </LI>
<Li> <a href = "#"> menu 3 </a> </LI>
</Ul>
</LI>
<Li> <a href = "#"> menu 4 </a>
<Ul>
<Li> <a href = "#"> menu 4 </a> </LI>
<Li> <a href = "#"> menu 4 </a> </LI>
<Li> <a href = "#"> menu 4 </a> </LI>
<Li> <a href = "#"> menu 4 </a> </LI>
<Li> <a href = "#"> menu 4 </a> </LI>
</Ul>
</LI>

<Li> <a href = "#"> menu 5 </a>
<Ul>
<Li> <a href = "#"> menu 5 </a> </LI>
<Li> <a href = "#"> menu 5 </a> </LI>
<Li> <a href = "#"> menu 5 </a> </LI>
<Li> <a href = "#"> menu 5 </a> </LI>
<Li> <a href = "#"> menu 5 </a> </LI>
</Ul>
</LI>
<Li> <a href = "#"> menu 6 </a>
<Ul>
<Li> <a href = "#"> menu 6 </a> </LI>
<Li> <a href = "#"> menu 6 </a> </LI>
<Li> <a href = "#"> menu 6 </a> </LI>
<Li> <a href = "#"> menu 6 </a> </LI>
<Li> <a href = "#"> menu 6 </a> </LI>
</Ul>
</LI>

</Ul>
</Div>

</Body>
</Html>

 

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.