Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums CSS Set active color in a menu

  • This topic is empty.
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #248296
    flavoni
    Participant

    Im trying to set an active, hover etc to categories in a menu.
    But im failing in my attempt, would appriciate some help.

    The site: klvunge.mystagingwebsite.com

    #248300
    Atelierbram
    Participant

    What have you tried so far? Can you show this in a demo? Do you mean highlighting the current menu item?

    #site-navigation .current-menu-item a {
      background-color: white;
      color: blue;
    }
    #site-navigation .current-menu-item a:hover {
        pointer-events: none;
        cursor: pointer;
    }
    

    Or do you mean using pseudo class selectors in general?

    #248304
    Paulie_D
    Member

    Also be aware that there is a difference between the :active pseudo-class and the “active/current” link.

    The latter is usually applied by javascript although there are other techniques depending on the size of the site.

    #248305
    flavoni
    Participant

    Atelierbram < Amazing, its worked!
    You´re the best!

    Is it somehow possible to achieve the same result when clicking on a project instead of a category-item, example https://klvunge.mystagingwebsite.com/2016/11/drawing-on-hell/ , where the category “drawings” should be highlighted in blue in this case.

    #248307
    Atelierbram
    Participant

    @flavoni Glad to be of help. Do you use (Chrome) Devtools to “inspect element” in the browser? Then you can see that dynamic markup for yourself … Anyway, here you can use the current-post-parent class set on the list item, like:

    #site-navigation .current-post-parent a {
      background-color: #fff;
      color: blue;
    }
    

    Can also combine those rules like:

    #site-navigation .current-menu-item a,
    #site-navigation .current-post-parent a {
      background-color: #fff;
      color: blue;
    }
    
Viewing 5 posts - 1 through 5 (of 5 total)
  • The forum ‘CSS’ is closed to new topics and replies.