Navbar highlight for current page

前端 未结 3 1015
野趣味
野趣味 2021-02-04 12:58

I was wondering how I would add the ability to add a highlight box the nav bar on the page your currently on. You know so people know what page their on.

Very much like

3条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-02-04 13:30

    If you have the same navigation bar in each HTML page of your website, then you can do like this:
    For example in index.html add class='active-page' to the first menu item:

    Then in the status.html add class='active-page' again but for the second item:

    And do this for all of your pages.

    Finally in your css write a class for active-page like this:

    #nav_bar ul li a.active-page
    {
      background-color:blue;
    }
    

提交回复
热议问题