[Resolved] scaling image in page header

Home Forums Support [Resolved] scaling image in page header

Home Forums Support scaling image in page header

Viewing 15 posts - 1 through 15 (of 19 total)
  • Author
    Posts
  • #241150
    Max

    Hey Tom

    Hope you and your family are well.

    I am using a full width background image in a page header.

    In another site I developed I already tested how to scale a graphic by giving it a class and then styling that class via @media css.

    However, I do not understand how I can do this with a bg image, because I cannot access the html to insert a class id.

    In summary, I want to scale one specific page header background image for screen, tablet, and mobile. How can I do that?

    #241218
    Tom
    Lead Developer
    Lead Developer

    You would most likely have to apply a different image to the element on different screen sizes using @media queries.

    This topic might give you an idea: https://generatepress.com/forums/topic/image-setting-for-mobileresponsive/

    #241229
    Max

    Yes I had already read that thread prior to starting this one.

    I understand that I can use three different images (3 different urls in the @ media).

    What I don’t understand is how do I identify the page header in the @media css?

    #241244
    Tom
    Lead Developer
    Lead Developer

    Can you link me to the page?

    #241245
    Max

    No.
    Local development xammp

    #241247
    Tom
    Lead Developer
    Lead Developer

    Hmm, have to guess then.

    Try this: .generate-content-header

    #241249
    Max

    Sorry. I dev local.

    If I use .generate-content-header won’t that be site wide and not just on my specific page?

    #241250
    Tom
    Lead Developer
    Lead Developer

    Use the Simple CSS meta box: https://wordpress.org/plugins/simple-css/

    #241252
    Max

    At present the background image does not scale down, and it does not remain centered.

    #241254
    Max

    I am running a child theme and so want to avoid using your css plugin if possible.

    Can’t I limit application of css be referring to page Id?

    #241259
    Max

    Hey Tom

    Ran some tests.

    I can control the bg image using:

    @media (max-width:480px) {.page-id-3291 .generate-content-header {width:35%;height:35%;}}

    So what css do I use to ensure that the bg image remains centered as the browser window is scaled down.

    At present the image remains (inplace) that is, as I scale down the browser window you just view the (leading) left hand side/edge of the bg image.

    #241261
    Max

    Ok this seems to be working:

    @media (max-width:480px) {.page-id-3291 .generate-content-header {background-position:center; width:100%;height:100%;}}
    @media (max-width:768px) {.page-id-3291 .generate-content-header {background-position:center; width:100%;height:100%;}}

    Any reason why it is not ok?

    #241263
    Tom
    Lead Developer
    Lead Developer

    The background-position is the important part there.

    Looks good to me 🙂

    #241267
    Max

    If I use sections and not page header for the background image. What identifier do I use in my css. That is, if using page header it is (.generate-content-header), but what is it if I use bg image in sections?

    #241269
    Tom
    Lead Developer
    Lead Developer

    Give your section a custom class in the settings, then you can use that class.

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