Active Menu Highlight CSS

后端 未结 11 930
孤独总比滥情好
孤独总比滥情好 2020-11-29 00:54

I want to highlight the current menu you have click. I\'m using CSS, but it is now working.

here is my css code:

#sub-header ul li:hover{ background-         


        
11条回答
  •  北荒
    北荒 (楼主)
    2020-11-29 01:46

    Add a class to the body of each page:

    
    

    Or if you're on the contact page:

    
    

    Then take this into consideration when you're creating your styles:

    #sub-header ul li:hover,
    body.home li.home,
    body.contact li.contact { background-color: #000;}
    
    #sub-header ul li:hover a,
    body.home li.home a,
    body.contact li.contact a { color: #fff; }
    

    Lastly, apply class names to your list items:

    
    

    This point, whenever you're on the body.home page, your li.home a link will have default styling indicating it is the current page.

提交回复
热议问题