Jump to content

Text when mouse over image in gallery?

Go to solution Solved by MayaViolet,

Recommended Posts

  • Solution
Posted

Hey @MattBairdSound - 

You should be able to use the gallery caption feature and some simple css to achieve this outcome. In order to differentiate the hover text from your current caption title text, you can wrap the hover text in html tags, so that we can target specifically this text. For example, if you have "Count Abdulla" in the caption already, add "<h2> hover text here </h2>" after in in the same line. 

Here's the CSS I would add:

 


.gallery-caption-wrapper {
overflow: visible; // this allows your hover text to be visible when we make it an absolute element, and move it up to appear on top of the image - if you want it to appear normally beneath the title, ignore this, and remove "position:absolute" below
}

.gallery-caption-wrapper h2 {
    position: absolute;
    text-align: center;
    width: 100% !important;
    transform: translateY(-250%); // this moves the text up - can be adjusted to match your needs
    margin: 0 !important;
transition: .5s; // allows for smooth fade in/out when we adjust opacity
opacity: 0;
}

.gallery-grid-item:hover {
.gallery-caption-wrapper h2 {
    opacity: 1;
transition: .5s;
}
.gallery-grid-item-wrapper img {
    opacity: 0.8; // changes opacity of image so text is more legible on hover
}
}

 

Depending on where and how you want it to appear, the above can be adjusted. Hope this helps!

Posted
18 hours ago, MattBairdSound said:

Thank you so much!

is there a way to have a different transform % value for mobile?

Add this code under

/* code for mobile */
@media screen and (max-width:767px) {
.gallery-caption-wrapper h2 {
    transform: translateY(-150%) !important;
}
}

 

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!)

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.