Jump to content

[Share] Gallery Hover with Caption and Clickable Link

Recommended Posts

If code doesn't work, you can share site url, I can check easier.

To achieve gallery hover with caption and clickable link, you can follow these steps.

#1. Hover on Gallery and click Edit Section

image.png.23bac2cf7c0b5a736d4d84b11390c983.png

#2. Enable Caption

image.png.335f364be71062bc4a306b11a119cf6c.png

#3. Hover on Gallery > Click Edit Gallery Images

image.png.d2a075a461f5c972ddedb4558b411055.png

#4. Type some captions and URL

image.png.1be517b344b4e7b4a78d126bc6347c28.png

We will have a result like this (here I use Gallery Grid, you can do similar with Gallery Strips or Gallery Masonry)

image.png.cbd0af258ec5d2013b2fb14c7ff55dea.png

#5.1. If you want to make Gallery with Hover Caption + Clickable for All Galleries, you can use this code to Custom CSS box

figure[class*="gallery"]:not(.gallery-slideshow-item) {
    position: relative;
}
.gallery-caption {
    position: static;
}
/* title */
.gallery-caption p.gallery-caption-content {
    position: absolute;
    left: 0;
    top: 0;
    right: 0;
    bottom: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 999;
    padding: 7%;
    transition: opacity ease 200ms !important;
    opacity: 0 !important;
pointer-events: none;
}
figure[class*="gallery"]:hover .gallery-caption-wrapper p.gallery-caption-content {
    opacity: 1 !important;
}
/* overlay */
div[class*="-item-wrapper"] a:after {
    background: #f4f6ea; /* overlay color */
    content: "";
    display: block;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    opacity: 0;
    transition: opacity ease 200ms !important;
}
figure[class*="gallery"]:hover div[class*="-item-wrapper"] a:after {
    opacity: 0.75;
}
figcaption {
    padding: 0 !important;
}

image.png.05063b870ecabda68bf063816efcb343.png

Result

image.png.e1713099c6322c99623f2b286c26c513.png

#5.2. If you wan to apply this for Specific Gallery, you need to find Gallery Section ID. Use below Tool.

In my example, we will have: 

section[data-section-id="66b35593870615758574885e"]

image.png.6b1116daf6c5d55fc7a6b30023769828.png

Next, use this CSS code

section[data-section-id="66b35593870615758574885e"] {
figure[class*="gallery"]:not(.gallery-slideshow-item) {
    position: relative;
}
.gallery-caption {
    position: static;
}
/* title */
.gallery-caption p.gallery-caption-content {
    position: absolute;
    left: 0;
    top: 0;
    right: 0;
    bottom: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 999;
    padding: 7%;
    transition: opacity ease 200ms !important;
    opacity: 0 !important;
pointer-events: none;
}
figure[class*="gallery"]:hover .gallery-caption-wrapper p.gallery-caption-content {
    opacity: 1 !important;
}
/* overlay */
div[class*="-item-wrapper"] a:after {
    background: #f4f6ea; /* overlay color */
    content: "";
    display: block;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    opacity: 0;
    transition: opacity ease 200ms !important;
}
figure[class*="gallery"]:hover div[class*="-item-wrapper"] a:after {
    opacity: 0.75;
}
figcaption {
    padding: 0 !important;
}}

#5.3. If you want to apply this for all Galleries on a specific page

You can edit page > Add a block > Choose Code

image.thumb.png.53868a1a78179994f4e8cc480835fdb6.png

and use this code into Code Block

<style>
figure[class*="gallery"]:not(.gallery-slideshow-item) {
    position: relative;
}
.gallery-caption {
    position: static;
}
/* title */
.gallery-caption p.gallery-caption-content {
    position: absolute;
    left: 0;
    top: 0;
    right: 0;
    bottom: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 999;
    padding: 7%;
    transition: opacity ease 200ms !important;
    opacity: 0 !important;
pointer-events: none;
}
figure[class*="gallery"]:hover .gallery-caption-wrapper p.gallery-caption-content {
    opacity: 1 !important;
}
/* overlay */
div[class*="-item-wrapper"] a:after {
    background: #f4f6ea; /* overlay color */
    content: "";
    display: block;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    opacity: 0;
    transition: opacity ease 200ms !important;
}
figure[class*="gallery"]:hover div[class*="-item-wrapper"] a:after {
    opacity: 0.75;
}
figcaption {
    padding: 0 !important;
}
</style>

image.thumb.png.c7295bc01ea38803b3036cda1ebb9ec1.png

#5.4. If you want to apply this for all Galleries on Blog Posts, you can use this code to Custom CSS box

body[class*="type-blog"].view-item {
figure[class*="gallery"]:not(.gallery-slideshow-item) {
    position: relative;
}
.gallery-caption {
    position: static;
}
/* title */
.gallery-caption p.gallery-caption-content {
    position: absolute;
    left: 0;
    top: 0;
    right: 0;
    bottom: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 999;
    padding: 7%;
    transition: opacity ease 200ms !important;
    opacity: 0 !important;
pointer-events: none;
}
figure[class*="gallery"]:hover .gallery-caption-wrapper p.gallery-caption-content {
    opacity: 1 !important;
}
/* overlay */
div[class*="-item-wrapper"] a:after {
    background: #f4f6ea; /* overlay color */
    content: "";
    display: block;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    opacity: 0;
    transition: opacity ease 200ms !important;
}
figure[class*="gallery"]:hover div[class*="-item-wrapper"] a:after {
    opacity: 0.75;
}
figcaption {
    padding: 0 !important;
}}

image.png.b0f873331d70f9533d3bac95a39a4371.png

#6. If you want to change the Overlay Color, you can adjust this line

image.png.e322a58cf6cd2e7f6234600f4a5ccf0e.png

If you want to change Caption text size/color, you can add color, font-size attribute to this code

image.png.a58edbc6dcba32770e2c3dec864bd978.png

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

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.