Use the same navigation code on different pages using css
Source: Internet
Author: User
After checking the relevant information, we found that flash was used to achieve this effect.
We need to go through the background. This is because I don't know much about it and I don't want to list it for the moment. Let's talk about the recently learned css.
How to use css to use the same navigation code on different pages
Principle:
Define an id for the body of each page
According to the inheritance feature of css ("It seems like this is the case, I am sorry to remember it is not very clear ")
Use the form of # body # nav
Implemented on different pages
The color of the link corresponding to the page is different from that of other links.
Let's take a look at my code:
General links can be defined as follows:
# Topnav a: hover,
# Topnav a: focus {background: #555 ;}
# Topnav a: active {
Background: #920D02;
Color: # fff;
}
Define a hyperlink different from a general link
# Home # nav-home,
# Contact # nav-contact {
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>
So far, the target is implemented ^_^
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