Using CSS to use the same navigation code on different pages

Source: Internet
Author: User
css| Navigation | page

Check the relevant data, in the process found that the use of flash to achieve this effect
Need to pass backstage, this because I do not understand, for the moment not to watch, talk about recently learning CSS

How to use CSS to implement the same navigation code on different pages

Principle:
By defining an ID for the body of each page
Based on the inheritance characteristics of the CSS ("seems to have this statement, I am sorry to remember not very clear")
Using the form of #body #nav a
Implemented in different pages
The color of the link that corresponds to the page is different from the color of the other links

Here's a look at my code:

Regular links can be defined as this
#topnav A:hover,
#topnav a:focus{background: #555;}
#topnav a:active {
Background: #920D02;
Color: #fff;
}

Define a hyperlink that is different from a generic link
#home #nav-home A,
#contact #nav-contact a {
Background: #91cc14;
Color: #000;
}

Xhtml
<body id= "Home" >
<div id= "Topnav" >
<ul>
<li id= "Nav-home" ><a href= "index-cn.shtml" > Home </a></li>
<li id= "nav-contact" ><a href= "contact.shtml" > Contact Us </a></li>
</ul>
</div>
At this point, the goal is achieved ^_^



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.