Jump to content

Image changing on hover, not working on all entities

Recommended Posts

Site URL: https://www.davai.squarespace.com

Hi all

I am having some issues with a HTML code, that is supposed to change a image to another when hovered above.

To access  the page, you might have to use the password "davai"

I have tried multiple solutions, but finally found one that actually worked (on one of the entities...)

You can find it in the second section under "Kompetencer". As you can see, it works on "adgangsudstyr" when you hover the mouse above the image, but it does not work on the wind turbine over "Vindmølleservice" or "Overfladebehandling"

The code i have gone for is:

<center>
<img src="URL to still image” 

onmouseover="this.src=’GIF image to replace still image" 

onmouseout="this.src=’URL to still image">
</center>

When the URL is added, it looks like this (this is the one added to the page)

<center>
<img src="https://images.squarespace-cdn.com/content/5f6873716e3d0466b9953dd9/1600854461689-UHACZYWZUG5CQPHJJLWV/icon-wind-turbine-service.png?content-type=image%2Fpng” 

onmouseover="this.src=’https://images.squarespace-cdn.com/content/5f6873716e3d0466b9953dd9/1600868753305-7LONEER0YHGEWO5QEBPT/Wind-turbine.gif?content-type=image%2Fgif’" 

onmouseout="this.src=’https://images.squarespace-cdn.com/content/5f6873716e3d0466b9953dd9/1600854461689-UHACZYWZUG5CQPHJJLWV/icon-wind-turbine-service.png?content-type=image%2Fpng’">
</center>

You should be able to access the images through the links.

 

Feel free to come up with alternate solutions, although i have tried out a few so far...

Link to comment
  • Replies 7
  • Views 3.4k
  • Created
  • Last Reply

This is easier to do with CSS, use 2 image tags with different classes inside a div.

<div class="imgSwap">
  <img class="img1" src="">
  <img class="img2" src="">
</div>
.img2 {
  display: none;
}

.imgSwap:hover .img1 {
  display: none;
}

.imgSwap:hover .img2 {
  display: inherit;
}

 

Link to comment

Well, clearly something is wrong with me, or the page.

i added this code:

HTML:

<div class="ImgSwap">
  <img class="Img1" src="https://images.squarespace-cdn.com/content/5f6873716e3d0466b9953dd9/1600854461689-UHACZYWZUG5CQPHJJLWV/icon-wind-turbine-service.png?content-type=image%2Fpng">
  <img class="Img2" src="https://images.squarespace-cdn.com/content/5f6873716e3d0466b9953dd9/1600868753305-7LONEER0YHGEWO5QEBPT/Wind-turbine.gif?content-type=image%2Fgif">
</div>

CSS:

.ImgSwap {
  display: none;
}

.ImgSwap:hover .Img1 {
  display: none;
}

.ImgSwap:hover .Img2 {
  display: inherit;
}

It still just shows nothing, not one nor the other

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.