Click "Reconstruction of the selected effect" in the navigation bar and click "Reconstruction of the selected effect" in the navigation bar.

Source: Internet
Author: User

Click "Reconstruction of the selected effect" in the navigation bar and click "Reconstruction of the selected effect" in the navigation bar.
I. Scenarios

Recently, a refactoring feature is that different styles are displayed after you click the link:

The Code is as follows. After I modify the style layout, use the bootstrap framework.

<! DOCTYPE html> Now we will focus on the implementation of the function.

The original code implements the link click style in this way, giving each link a different class,

<li class="menu01"><a href="page1.html">page1</a></li><li class="menu02"><a href="page2.html">page2</a></li><li class="menu03"><a href="page3.html">page3</a></li>

The following is defined on the page1.html page:

.menu01{background-color:#5dc1d1;border-radius:4px;}

The definition on the page2.html page is as follows:

.menu02{background-color:#5dc1d1;border-radius:4px;}

On the page3.html page, define:

.menu03{background-color:#5dc1d1;border-radius:4px;}

Menu is a public module of page1.html, page2.html, and page3.html, which is shared by include. In this way, the style of other links does not take effect when different pages are called. Therefore, different styles can be displayed on the clicked link.

However, this approach is very bad. If a style has multiple pages, it will be overwritten several times. Different class names correspond to the same style.

Such code is intolerable. The following uses a short section of js to implement the same function.

Ii. Rebuilding with js

The Code is as follows:

<! DOCTYPE html> 

Iii. Similar effects

The implementation method is as follows: add an active style to the user request url and the user request url.

<Div class = "btn-toolbar"> <div class = "btn-group"> {% url "addpermissionurl" as theaddpermissionurl %} <a class = "btn-default {% if request. path = theaddpermissionurl %} active {% endif %} "href = {theaddpermissionurl }}> <span class =" glyphicon-edit "> </span> Create permission </ >{% url "listpermissionurl" as thelistpermissionurl %} <a class = "btn-default {% if request. path = thelistpermissionurl %} active {% endif %} "href ={{ thelistpermissionurl }}> <span class =" glyphicon-list "> </span> permission list </> </div>

 

 

 

Starof, the author of this article, is constantly learning and growing because of the changing knowledge. The content of this article is also updated from time to time. To avoid misleading readers and facilitate tracing, Please repost the Source: Ghost.

 

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.