Site logo

[Resolved] Adding CSS to Header Element

Home Forums Support [Resolved] Adding CSS to Header Element

Home Forums Support Adding CSS to Header Element

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #2195315
    Max

    Hello,
    I need two different styled header navigation. One for front page and another for all other pages.
    I created 2 different Elements (type header). But can not figure out how to add different styling for them (there no field to add css class).

    #2195346
    Max

    So far I find out one of the methods to achieve this, is to use pseudo-classes:

    body:not(.home) .main-navigation{
    /*my styling here*/
    }
    #2195365
    Fernando
    Customer Support

    Hi Sergly,

    You can select specific Pages to include and exclude in the Display Rules of an Element.

    If you’re adding specific CSS, you can indeed use pseudo classes.

    Kindly let us know if further assistance is needed regarding this. 🙂

    #2195372
    Max

    Yes, we can definitely do custom CSS using pseudo classes, but it’s not very convenient (it’s overloading the system, not kind of clean code like BEM methodology).
    Just curious why do not add Element Classes Field for Header Element like other elements have, for example:

    Thank you.

    #2195393
    Fernando
    Customer Support

    Good point. You may also just add a class there instead of using pseudo classes. 🙂

    #2195772
    Max

    Fernando, no you can not. Actually, it’s what this topic is about.

    Element Header does not have this field:

    Page Hero has, but we speaking about Header navigation.

    #2195782
    David
    Staff
    Customer Support

    Hi there,

    if you need to custom style the navigation then then body_class method you used here is the way to go:

    https://generatepress.com/forums/topic/adding-css-to-header-element/#post-2195346

    #2195791
    Max

    Got it, Thank you, Fernando and David.

    #2195804
    David
    Staff
    Customer Support

    You’re welcome

Viewing 9 posts - 1 through 9 (of 9 total)
  • You must be logged in to reply to this topic.