Two examples of creating navigation menus with CSS

Source: Internet
Author: User

Original tutorial. For more information, see the source: Two examples of creating navigation menus using CSS on the webpage tutorial network.
Currently, CSS + XHTML is used to create a webpage. Generally, a webpage requires navigation. There are two types of navigation: horizontal and vertical.
1. Vertical navigation example: (Click here to view the demo effect)
(1) CSS file: (save as vertical.css)

The code is as follows: Copy code

H1, h2
{
Font: normal 200%/100% Garamond, "", 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:
}
# 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;
}
<! DOCTYPE html
PUBLIC "-// W3C // dtd xhtml 1.1 // EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<Html xmlns = "http://www.w3.org/1999/xhtml" xml: lang = "en">
<Head>
<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">
<H1> vertical navigation menu created by CSS on the webpage teaching Network </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"> website creation guide </a> </li>
<Li> <a href = "/news/index.htm" tabindex = "4"> on-site news </a> </li>
<Li> <a href = "/web" tabindex = "5"> webpage creation </a> </li>
<Li> <a href = "/program" tabindex = "6"> network programming </a> </li>
</Ul>
</Div>
<Div id = "main">
<H2 id = "start"> homepage <P>
Statement: 1) This site does not guarantee the integrity and security of the software or tutorials provided. 2) Check for viruses before use and download the corresponding reader. 4) do not delete this instruction file if you have reprinted the resources provided by this site. 5) All programs provided on this site are collected online. If this program involves or infringes on your copyright, please write a letter to inform us immediately. 6) the software provided on this site is only available for research and use. Please delete it within 24 hours after the download. Do not use it for commercial purposes. All consequences caused by this will be irrelevant to this site. This site provides service projects for you to build online mall English-Chinese Translation Advertising Program Development materials for sale note: Recommended use: WinRAR V3.0 or later version unzip this site software unzip password: Web teaching Network: on the altar: /bbs </p>
</Div>
<Div id = "footer">
<P>
Copyright © 2005. All Rights Reserved.
</P>
</Div>
</Body>
</Html>

2. Horizontal navigation example:

(1) CSS file: (save as horizontal.css)

H1, h2
{
Font: normal 200%/100% Garamond, "", 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:
}

# 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;
}

 

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.