Two examples of creating a navigation menu with CSS

Source: Internet
Author: User
Tags documentation header xmlns
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" >
&LT;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>
&LT;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!



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.