Jump to content

CSS Hover on gallery , show caption text on photo

Recommended Posts

Site URL: https://www.relead.dk/forside-ny

Hi all,

Trying to make a hover function on our employee gallery, showing their contact info (caption) when hovering the mouse over image. 
Like this: https://www.w3schools.com/howto/tryit.asp?filename=tryhow_css_image_overlay_fade

But I am having a hard time controlling the placement of caption text. Also hiding the white space below each image. I only want 5px space between.

My code:

.gallery-grid-item-wrapper:hover .gallery-caption .gallery-caption-grid-simple {
  visibility: visible;
  opacity: 1;
}

.gallery-caption {
  visibility: hidden;
  opacity: 0;
}

Hopefully some of you can help me 🙂

Thanks

/Morten

Link to comment
  • Replies 2
  • Created
  • Last Reply

I got this far... But all captions is showed on the first row. Because of the absolute position i guess.

code:

/* Gallery Block Customisation */
.gallery-caption {
  visibility: hidden;
  opacity: 0;
  position: absolute;
  top:0;
  background: rgba(29, 106, 154, 0.72);
  height: 268px;
  width: 398px;
  
}

.gallery-grid-item:hover .gallery-caption {
  visibility: visible;
  opacity: 1;
}

 

Link to comment

This works 🙂

/* Gallery Block Customisation */
.gallery-caption {

  position:absolute;
  top:0;
  visibility: hidden;
  opacity: 0;
  background: #E0E0DA;
  height: 90%;
  width: 100%;
  text-align: center;
  transition: opacity .2s, visibility .2s;
 
}

.gallery-grid-item:hover .gallery-caption {
  visibility: visible;
  opacity: 1;

}
.gallery-grid-item {
  position:relative;
}
.gallery-grid-wrapper {
  position:relative;
}

 

Link to comment

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.