[Resolved] Centering site-logo (using generate_before_header hook)

Home Forums Support [Resolved] Centering site-logo (using generate_before_header hook)

Home Forums Support Centering site-logo (using generate_before_header hook)

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #1435876
    Sue

    I’m having trouble centering the site-logo I set up using the before_header hook. Right now the 960 px wide image is off to the side, and I can’t figure out how to center it above the rest of the content.

    #1435891
    Elvin
    Staff
    Customer Support

    Hi Sue,

    You can try adding this CSS code to your site.

    .site-logo {
        max-width: 100%;
        display: flex;
        justify-content: center;
    }

    Here’s a demo video of how it’ll look like.
    https://share.getcloudapp.com/NQur9Qqo

    Let us know if it works for you.

    #1435895
    Leo
    Staff
    Customer Support

    Hi Sue,

    Any specific reasons why you are using a hook instead of the default logo field under Customizer > Site Identity?

    #1435918
    Sue

    Hooray — Elvin’s solution worked! Thanks.
    Leo: The reason I was using hooks was because there are going to be different header images on each page, and my impression was that I have to use hooks for that.

    #1435923
    Elvin
    Staff
    Customer Support

    Nice one! That makes sense, I see that you’re utilizing the display rules. Great job. πŸ˜€

    No problem. Always glad to be of any help.:)

    #1435927
    Sue

    Thanks again! Closing the topic. πŸ™‚

    #1436018
    Leo
    Staff
    Customer Support

    How many different logo images are you using?

    Personally I’d go with the filter solution instead of hook:
    https://docs.generatepress.com/article/generate_logo/

    Couple advantages of using the filter instead of a custom hook:

    – The original HTML markup of the logo is kept

    – The filter solution allows you to write one snippet and take care of multiple display rules as opposed to one element per display rule.

    #1437133
    Sue

    I spent a lot of time staring at that page and wasn’t sure how I would actually DO that, but I think I get it — I’d have to install a plugin like Code Snippets first. I will try it and see if I can figure it out!

    #1437406
    Leo
    Staff
    Customer Support

    Sounds good.

    Just comment here again if you need more info πŸ™‚

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