css| Menu | create | navigation
Original tutorial, reproduced please indicate the source: Web Teaching Network
Two examples of creating a navigation menu with CSS
Now use css+xhtml to make Web pages, usually web pages need to navigate, there are usually two kinds of navigation: horizontal and vertical.
1. Vertical Navigation Example: ( Click here to explore the demo effect )
(1) CSS file: (Save as VERTICAL.CSS)
H1, H2
{
Font:normal 200%/100% Garamond, "Song Body", serif;
margin-bottom:0px;
Color: #630;
Background:transparent;
}
H2
{
font-size:150%;
}
#header
{
padding:5px;
Border-bottom: #ccc 1px solid;
}
#main
{
margin-left:210px;
padding:5px;
}
#footer
{
Clear:both;
padding:5px;
Border-top: #ccc 1px solid;
}
#navigation
{
Float:left;
width:200px;
padding:5px;
}
#navigation ul
{
margin-left:0;
padding-left:0;
List-style-type:none;
Font-family: Song Body
}
#navigation A, li#current
{
Display:block;
width:180px;
Text-decoration:none;
padding:5px;
Border-bottom: #fff solid 1px;
Background-color: #630;
Color: #fff;
}
#navigation a:hover, #navigation a:active, #navigation a:focus, li#current
{
Background-color: #c90;
Color: #000;
}
(2) Complete HTML file: (Save as Vertical.htm)
<! DOCTYPE html
Public "-//w3c//dtd XHTML 1.1//en" "Http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd" >
<title>vertical navigation</title>
<meta http-equiv= "Content-type" content= "application/xhtml+xml; charset=gb2312 "/>
<link href= "Vertical.css" rel= "stylesheet" type= "Text/css"/> <body>
<div id= "Header" >
</div>
<div id= "Navigation" >
<ul>
<li><a href= "#start" tabindex= "1" > Skip navigation </a></li>
<li id= "Current" > Home page </li>
<li><a href= "/jianzhan" tabindex= "3" > Construction Station Guide </a></li>
<li><a href= "/news/index.htm" tabindex= "4" > Station news </a></li>
<li><a href= "/web" tabindex= "5" > Web page Making </a></li>
<li><a href= "/program" tabindex= "6" > Network programming </a></li>
</ul>
</div>
<div id= "Main" >
<H2 id= "Start" > Home <p>
Disclaimer: 1 This site does not guarantee the integrity and security of the software or tutorials provided. 2 Please check the virus before use, download the corresponding reader. 4) Reprint the resources provided by this site do not delete this documentation. 5 The site to provide the procedures are online collection, if the program involved or infringe on your copyright, please write to inform us immediately. 6 The site to provide software only for research, please delete within 24 hours of download, do not use for commercial purposes, resulting in all the consequences of this site has nothing to do. The website provides the service project for you to build the station on-line shopping center English-Chinese Translation Advertisement program development Material Sale NOTE: Recommended use: WinRAR V3.0 above version decompression this website software decompression password: www.webjx.com Web page: http://www.webjx.com Forum: http ://www.webjx.com/bbs </p>
</div>
<div id= "Footer" >
<p>
copyright©2005 webjx.com. All Rights Reserved.
</p>
</div>
</body>
2. Horizontal Navigation Example: ( Click here to explore the demo effect )
(1) CSS file: (Save as HORIZONTAL.CSS)
H1, H2
{
Font:normal 200%/100% Garamond, "Song Body", serif;
margin-bottom:0px;
Color: #630;
Background:transparent;
}
H2
{
font-size:150%;
}
#header
{
padding:5px;
Border-bottom: #ccc 1px solid;
}
#main
{
margin-left:210px;
padding:5px;
}
#footer
{
Clear:both;
padding:5px;
Border-top: #ccc 1px solid;
}
#navigation
{
Float:left;
width:200px;
padding:5px;
}
#navigation ul
{
margin-left:0;
padding-left:0;
List-style-type:none;
Font-family: Song Body
}
#navigation A, li#current
{
Display:block;
width:180px;
Text-decoration:none;
padding:5px;
Border-bottom: #fff solid 1px;
Background-color: #630;
Color: #fff;
}
#navigation a:hover, #navigation a:active, #navigation a:focus, li#current
{
Background-color: #c90;
Color: #000;
}
(2) Complete HTML file: (Save as Horizontal.htm)
<! DOCTYPE html
Public "-//w3c//dtd XHTML 1.1//en" "Http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd" >
<title>vertical navigation</title>
<meta http-equiv= "Content-type" content= "application/xhtml+xml; charset=gb2312 "/>
<link href= "Horizontal.css" rel= "stylesheet" type= "Text/css"/> <body>
<div id= "Navigation" >
<ul>
<li><a href= "#start" tabindex= "1" > Skip navigation </a></li>
<li id= "Current" > Home page </li>
<li><a href= "/jianzhan" tabindex= "3" > Construction Station Guide </a></li>
<li><a href= "/news/index.htm" tabindex= "4" > Station news </a></li>
<li><a href= "/web" tabindex= "5" > Web page Making </a></li>
<li><a href= "/program" tabindex= "6" > Network programming </a></li>
</ul>
</div>
<H2 id= "Start" > Home <p>
Disclaimer: 1 This site does not guarantee the integrity and security of the software or tutorials provided. 2 Please check the virus before use, download the corresponding reader. 4) Reprint the resources provided by this site do not delete this documentation. 5 The site to provide the procedures are online collection, if the program involved or infringe on your copyright, please write to inform us immediately. 6 The site to provide software only for research, please delete within 24 hours of download, do not use for commercial purposes, resulting in all the consequences of this site has nothing to do. The website provides the service project for you to build the station on-line shopping center English-Chinese Translation Advertisement program development Material Sale NOTE: Recommended use: WinRAR V3.0 above version decompression this website software decompression password: www.webjx.com Web page: http://www.webjx.com Forum: http ://www.webjx.com/bbs </p>
</body>
Through the above two examples want you to have a more in-depth understanding of CSS!