Jump to content

Enlarge image AND show caption on hover: Simple Grid

Go to solution Solved by Amy_Faire_,

Recommended Posts

Using custom CSS I've figured out how to enlarge a gallery image on hover using transform:scale


I've also figured out how to show a gallery caption on hover using the widely circulated code available on a number of SS designers sites and youTube channels.

But is it possible to do both at once without the caption blocking the image?

https://welcome-trial.squarespace.com/discography
password: 5678

Link to comment
  • 2 weeks later...
On 9/21/2023 at 10:46 PM, Amy_Faire_ said:

Sorry, I have reinstated the 5678 password. I currently just have the code set to caption on hover.

Use this CSS code to make image enlarge on hover

/* Image enlarge on hover */
.gallery-grid-item-wrapper {
    overflow: hidden;
}
.gallery-grid-item-wrapper img, figure:hover img {
    transition: all 0.3s ease;
}
figure.gallery-grid-item:hover img {
    transform: scale(1.3);
}

Note: this code will run on all galleries

If you want code run on Discography page only, use this new code

/* Image enlarge on hover */
body#collection-64c16d70de89d22a79658d55 {
.gallery-grid-item-wrapper {
    overflow: hidden;
}
.gallery-grid-item-wrapper img, figure:hover img {
    transition: all 0.3s ease;
}
figure.gallery-grid-item:hover img {
    transform: scale(1.3);
}}

 

Email me if you have need any help (free, of course.). Answer within 24 hours. 
Or send to forum message

Contact Customer Care - Learn CSS - Buy me a coffee (thank you!)

Link to comment

Thank you for your response tuanphanI really appreciate your help.

The code you provided does enlarge the image however I didn't want the overflow to be hidden so I changed the code to this:

/* Image enlarge on hover */
.gallery-grid-item-wrapper img,
figure.gallery-grid-item:hover img {
    transition: all 0.3s ease;
}

figure.gallery-grid-item:hover img {
    transform: scale(1.3);
}

Now my only issue is that the gallery caption background doesn't enlarge so it's a dark square in the center of the enlarged album image on hover. I tried applying 'transform' to the caption background, got it to work, but it was then blocking the album cover, so then the album cover no longer enlarged. Any thoughts?

Link to comment
  • Solution

Actually, I got it to work! I used z-index. Thank you for your help

.gallery-caption-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    z-index: 1; 
}

.gallery-grid-item:hover .gallery-caption {
    opacity: 1;
    transform: scale(1.3); 
    z-index: 2;
}


 

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

×
×
  • Create New...

Squarespace Webinars

Free online sessions where you’ll learn the basics and refine your Squarespace skills.

Hire a Designer

Stand out online with the help of an experienced designer or developer.