Use CSS to mark the effect of the current page on the webpage navigation bar

Source: Internet
Author: User

[Document of the fire School of building site] the current page-for example, if the current page is the homepage, the color of the homepage on the navigation bar is different from that on other topics, which is used to give a clear indication to the viewer. Next, let's take a look at the specific practice. The basic implementation of a menu is not much different from that of a General CSS menu. We will focus on how to implement the current page.

Set Menu has five columns: home, about, products, services, contact, respectively for each column an ID, m1-m5, CSS can be written as follows:

# Home # nav li # m1,
# About # nav li # m2,
# Products # nav li # m3,
# Services # nav li # m4,
# Contact # nav li # m5 a {color: # FFF; background: # DC4E1B url(navbg.gif) no-repeat ;}

Xhtml:

<Ul id = "nav">
<Li id = "m1"> <a href = "index.html"> Home </a> </li>
<Li id = "m2"> <a href = "about.html"> About </a> </li>
<Li id = "m3"> <a href = "products.html"> Products </a> </li>
<Li id = "m4"> <a href = "services.html"> Services </a> </li>
<Li id = "m5"> <a href = "contact.html"> Contact </a> </li>
</Ul>

Then, separate the bady labels for each page with an independent ID. For example, the homepage ID is home, and the rest is similar.

The advantage of this approach is that the menus on each page are the same, which makes it easy to modify and include dynamic pages.

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.