Are you a GenerateCustomer?

Do you have an active GP Premium or GenerateBlocks Pro license key?

Create a GenerateSupport account for GeneratePress and GenerateBlocks support in one dedicated place.

Create an account
Already have a GenerateSupport account? Login

Just browsing?

Feel free to browse the forums. Support for our free versions is provided on WordPress.org (GeneratePress, GenerateBlocks).

Want to become a premium user? Learn more below.

Zoom effect on background image

  • Hello,
    I am trying to create a zoom effect on an image or background image, with the effect remaining within the dimensions and border of the container. I would like the zoom to only affect the image without enlarging the entire container.
    Something like on at the bottom of your theme “Wilder” home page.
    How can I do this?
    Thanks a lot!

  • Hi Luca. This would work easier with an image.

    1. Set the image’s parent container to OVERFLOW-X and OVERFLOW-Y to hidden from the Position settings on the right.

    Overflow controls

    2. Select the image and add a TRANSITION from the Effects panel.

    Effects panel

    3. With the image selected, select the Hover selector and add a Transform effect with a TRANSFORM TYPE of Scale and a SCALE value of 1.1 from the Effects panel.

    Scale effect

    Let me know how it goes!

  • Hi George, it works!
    There is still one problem: the corners of the image border are rounded, but when hovering, they return to right angles. I added the border radius value to the hover section as well, but that didn’t solve the problem…

  • Hi again.

    Please, remove the border radius from the image, also from the hover selector. Apply the border radius to the image container instead.

  • Perfect!
    Thanks a lot

  • No problem!

  • @George Is it possible to create a hover effect with a background image?

  • Yes, but you need GenerateBlocks Pro for this, otherwise, it can be achieved with some custom CSS. Let me know your preference.

  • Hi George,
    if it’s not too hard (I’m not a professional website builder), let’s try with CSS 🙂

  • No problem, just follow my lead!

    Create a container and set POSITION to Relative. Also, set OVERFLOW-X and OVERFLOW-Y to hidden.

    Container position to Relative - OVERFLOW hidden

    Set some paddings or a fixed height.

    Container fixed height

    Set a custom class to this container, eg: hover-scale-bg

    Container custom class

    Insert this CSS:

    .hover-scale-bg::before {
        content: '';
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background-image: url('your-image.jpg');
        background-size: cover;
        background-position: center;
        transition: transform 0.4s ease;
        z-index: -1;
    }
    
    .hover-scale-bg:hover::before {
        transform: scale(1.1);
    }

    Insert it either in the Customizer or inside you child theme.
    https://docs.generatepress.com/article/adding-css/

    Let me know how it goes!

  • I do, but it doesn’t work… I think I do all as you said, can you check in private link. It is at the page bottom 🙂

  • Please, do not upload a background image on the container, you need to remove that.

    Then, in your CSS, you need to add the URL of your image:

    .hover-scale-bg::before {
        content: '';
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background-image: url('https://www.staging2.baitarondanino.it/wp-content/uploads/2021/11/Esterni-Gallery-6.jpg');
        background-size: cover;
        background-position: center;
        transition: transform 0.4s ease;
        z-index: -1;
    }
    
    .hover-scale-bg:hover::before {
        transform: scale(1.1);
    }

    As you can see the actual image is being added in CSS through a ::before pseudo-element.

  • Ah ok, thanks.
    I thought I could achieve the effect with a different image for each container, but instead with this method I use a single image for all the different containers…

  • You can change the image URL in the CSS provided to have a different image, it doesn’t have to be the same. You could add another class next to the hover-scale-bg one, let’s say image-2 or image-3.

    Then have this:

    .hover-scale-bg::before {
        content: '';
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background-size: cover;
        background-position: center;
        transition: transform 0.4s ease;
        z-index: -1;
    }
    
    .hover-scale-bg:hover::before {
        transform: scale(1.1);
    }
    
    .hover-scale-bg.image-2::before {
        background-image: url('https://www.staging2.baitarondanino.it/wp-content/uploads/2021/11/another-image.jpg');
    }
    
    .hover-scale-bg.image-3::before {
        background-image: url('https://www.staging2.baitarondanino.it/wp-content/uploads/2021/11/yet-another-image.jpg');
    }

    Let me know if you want further explanation.

  • I try, only first code too, but doesn’t work…
    I don’t understand where is the problem

  • Ok, please remove z-index: -1;

    from this code:

    .hover-scale-bg::before {
        content: '';
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background-size: cover;
        background-position: center;
        transition: transform 0.4s ease;
        z-index: -1;
    }
Viewing 16 posts - 1 through 16 (of 21 total)
  • You must be logged in to reply to this topic.