Div + CSS navigation menu code, pretty good. Share

Source: Internet
Author: User
First, if you want to see the demo, create a notebook, add the following code, save it, change the file name to abc.htm, and run it directly.
Copy code

<Style type = "text/CSS">
# Nav {
Height: 44px;
Width: 600px;
Background: # FFF;
}
. Vline {
Background: #999;
Width: 1px;
Height: 20px;
}
# Nav ul {
Margin: 0px;
Padding: 0px;
List-style-type: none;
}
# Nav Li {
Float: left;
Font-family: Arial;
Font-weight: bold;
Font-size: 12px;
Text-align: center;
}
# Nav Li {
Display: block;
Width: 84px;
Line-Height: 28px;
Color: #666;
Text-Decoration: none;
Border-top: 4px solid #0f35a5;
}
# Nav Li A: hover {
Color: #7c8dd9;
Border-top: 4px solid #7c8dd9;
}
</Style>
<Div id = "nav"> <ul> <li> <a href = "#"> snail bait online </a> </LI> <li class = "vline"> </LI>
<Li> <a href = "#"> snail bait online </a> </LI> <li class = "vline"> </LI>
<Li> <a href = "#"> snail bait online </a> </LI> <li class = "vline"> </LI>
<Li> <a href = "#"> snail bait online </a> </LI> <li class = "vline"> </LI>
<Li> <a href = "#"> snail bait online </a> </LI> <li class = "vline"> </LI>
<Li> <a href = "#"> snail bait online </a> </LI> <li class = "vline"> </LI>
<Li> <a href = "#"> snail bait online </a> </LI> <li class = "vline"> </LI>
</Ul> </div>

Second:

[Code] <! Doctype HTML public "-// W3C // dtd xhtml 1.0 transitional // en" "<a href =" http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd "target =" _ blank "> http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd </a>">
<HTML xmlns = "<a href =" http://www.w3.org/1999/xhtml "target =" _ blank "> http://www.w3.org/1999/xhtml </a>">
<Head>
<Meta http-equiv = "Content-Type" content = "text/html; charset = gb2312"/>
<Title> <a href = "http://blog.h3bbs.com" target = "_ blank"> Tianya blog </a> pure CSS pop-up menu </title>
<Style type = "text/CSS">
<! --
Body {
Margin-top: 0px;
Margin-bottom: 0px;
Margin-left: auto;
Margin-Right: auto;
Background: # FFF;
Text-align: center;
Color: #333;
Font-family: Arial, verdana, sans-serif;
}

# Topbanner {
Margin-left: auto;
Margin-Right: auto;
Width: 580px;
Height: 40px;
Border-bottom: 5px solid # ff9900;
}

# Bottom {
Margin-left: auto;
Margin-Right: auto;
Width: 580px;
Height: 40px;
Border-top: 5px solid # ff9900;
}

/* Menu style definition */
# Menu {
Clear: both;
Margin-Right: auto;
Margin-left: auto;
Width: 580px;
Height: 24px;
Color: # FFF;
Background-color: #900;
}

/* Main menu style definition */
. Mainmenu {
Float: left;
Width: 64px;
Font-size: 13px;
Color: # FFF;
Border-left: 1px solid #999;
}

. Menucontent {
Float: left;
Width: 80px;
Height: 20px;
Color: # FFF;
Padding-top: 4px;
}

. Menucontent A: link {
Color: # FFF;
Display: block;
Text-Decoration: none;
}

. Menucontent A: visited {
Color: # FFF;
Display: block;
Text-Decoration: none;
}

. Menucontent A: hover {
Color: # FFF;
Text-Decoration: none;
Background-color: #000;
}

/* Sub-menu style definition */
. Submenu {
Clear: both;
Float: left;
Position: absolute;
Width: 80px;
Padding: 0px;
Font-size: 13px;
}

. Submenu ul {
Background-color: # Eee;
List-style-type: none;
Width: 82px;
Line-Height: 24px;
}

. Submenu Li {
Border-bottom: # CCC 1px dotted;
}

. Submenu Li A: Link, A: visited {
Color: #333;
Display: block;
Text-Decoration: none;
}

. Submenu Li A: hover {
Color: # FFF;
Text-Decoration: none;
Background-color: #900;
Border-top: 1px solid # FFF;
}
-->
</Style>
</Head>

<Body>
<Div id = "topbanner"> </div>
<Div id = "menu">

<Div class = "mainmenu" onmouseover = "submenu1.style. Display = 'block'" onmouseout = "submenu1.style. Display = 'none'">
<Div class = "menucontent"> <a href = "#" Title = "#"> Tianya homepage </a> </div>

<Div class = "mainmenu" onmouseover = "submenu2.style. Display = 'block'" onmouseout = "submenu2.style. Display = 'none'">
<Div class = "menucontent"> <a href = "#" Title = "#"> Tianya log </a> </div>

<Div class = "mainmenu" onmouseover = "submenu3.style. Display = 'block'" onmouseout = "submenu3.style. Display = 'none'">
<Div class = "menucontent"> <a href = "#" Title = "#"> electronic communication </a> </div>

<Div class = "mainmenu" onmouseover = "submenu4.style. Display = 'block'" onmouseout = "submenu4.style. Display = 'none'">
<Div class = "menucontent"> <a href = "#" Title = "#"> network technology </a> </div>

<Div class = "mainmenu" onmouseover = "submenu5.style. Display = 'block'" onmouseout = "submenu5.style. Display = 'none'">
<Div class = "menucontent"> <a href = "#" Title = "#"> love in Tianya </a> </div>

<Div class = "mainmenu" onmouseover = "submenu6.style. Display = 'block'" onmouseout = "submenu6.style. Display = 'none'">
<Div class = "menucontent"> <a href = "#" Title = "#"> leisure and entertainment </a> </div>

<Div class = "mainmenu" onmouseover = "submenu7.style. Display = 'block'" onmouseout = "submenu7.style. Display = 'none'">
<Div class = "menucontent"> <a href = "#" Title = "#"> Computer Information </a> </div>

</Div>

<Div class = "submenu" style = "display: none; margin-left:-40px;" onmouseover = "submenu1.style. display = 'block' "onmouseout =" submenu1.style. display = 'none' "id =" submenu1 ">
<Ul>
<Li> <a href = "#" Title = "Tianya Homepage"> Tianya homepage </a> </LI>
<Li> <a href = "#" Title = "Tianya Homepage"> Tianya homepage </a> </LI>
<Li> <a href = "#" Title = "Tianya Homepage"> Tianya homepage </a> </LI>
<Li> <a href = "#" Title = "Tianya Homepage"> Tianya homepage </a> </LI>
</Ul>
</Div>


<Div class = "submenu" style = "display: none; margin-left: 41px;" onmouseover = "submenu2.style. display = 'block' "onmouseout =" submenu2.style. display = 'none' "id =" submenu2 ">
<Ul>
<Li> <a href = "#" Title = "Tianya log"> Tianya log </a> </LI>
<Li> <a href = "#" Title = "Tianya log"> Tianya log </a> </LI>
<Li> <a href = "#" Title = "Tianya log"> Tianya log </a> </LI>
<Li> <a href = "#" Title = "Tianya log"> Tianya log </a> </LI>
</Ul>
</Div>



<Div class = "submenu" style = "display: none; margin-left: 122px;" onmouseover = "submenu3.style. display = 'block' "onmouseout =" submenu3.style. display = 'none' "id =" submenu3 ">
<Ul>
<Li> <a href = "#" Title = ""> electronic communication </a> </LI>
<Li> <a href = "#" Title = ""> electronic communication </a> </LI>
<Li> <a href = "#" Title = ""> electronic communication </a> </LI>
<Li> <a href = "#" Title = ""> electronic communication </a> </LI>
</Ul>
</Div>


<Div class = "submenu" style = "display: none; margin-left: 203px;" onmouseover = "submenu4.style. display = 'block' "onmouseout =" submenu4.style. display = 'none' "id =" submenu4 ">
<Ul>
<Li> <a href = "#" Title = "Network Technology"> network technology </a> </LI>
<Li> <a href = "#" Title = "Network Technology"> network technology </a> </LI>
<Li> <a href = "#" Title = "Network Technology"> network technology </a> </LI>
<Li> <a href = "#" Title = "Network Technology"> network technology </a> </LI>
</Ul>
</Div>


<Div class = "submenu" style = "display: none; margin-left: 284px;" onmouseover = "submenu5.style. display = 'block' "onmouseout =" submenu5.style. display = 'none' "id =" submenu5 ">
<Ul>
<Li> <a href = "#" Title = ""> </a> </LI>
<Li> <a href = "#" Title = ""> </a> </LI>
<Li> <a href = "#" Title = ""> </a> </LI>
<Li> <a href = "#" Title = ""> </a> </LI>
</Ul>
</Div>


<Div class = "submenu" style = "display: none; margin-left: 365px;" onmouseover = "submenu6.style. display = 'block' "onmouseout =" submenu6.style. display = 'none' "id =" submenu6 ">
<Ul>
<Li> <a href = "#" Title = "leisure and entertainment"> leisure and entertainment </a> </LI>
<Li> <a href = "#" Title = "leisure and entertainment"> leisure and entertainment </a> </LI>
<Li> <a href = "#" Title = "Snail line"> snail line </a> </LI>
<Li> <a href = "#" Title = "Snail line"> snail line </a> </LI>
</Ul>
</Div>

<Div class = "submenu" style = "display: none; margin-left: 446px;" onmouseover = "submenu7.style. display = 'block' "onmouseout =" submenu7.style. display = 'none' "id =" submenu7 ">
<Ul>
<Li> <a href = "#" Title = "Snail line"> snail line </a> </LI>
<Li> <a href = "#" Title = "Snail line"> snail line </a> </LI>
<Li> <a href = "#" Title = "Snail line"> snail line </a> </LI>
<Li> <a href = "#" Title = "Snail line"> snail line </a> </LI>
</Ul>
</Div>

<Div id = "bottom"> </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.