• [Wébinaire 13 novembre 2025] Comment l’IA optimise la performance marketing in HubSpot ?

    S'inscrire

CMS Development

mariana_pic
Contributeur | Partenaire solutions Platinum
Contributeur | Partenaire solutions Platinum

Help with Social Media Hover

Résolue

Hi!

I'm having problems with the hover of my social media buttons.

I have an HTML module with the following code:

 

<!--Facebook-->
<a target="_blank" href="https://www.facebook.com/apogeeITservices">
<img src="http://cdn2.hubspot.net/hubfs/492950/Apogee/Icons/Social_Media_Icons/Apogee-website-facebook.png" alt="facebook" height="30px" width="30px"
onmouseover="this.src='http://cdn2.hubspot.net/hubfs/492950/Apogee/Icons/Social_Media_Icons/Apogee-website-facebook-hover.p...';"
onmouseout="this.src='http://cdn2.hubspot.net/hubfs/492950/Apogee/Icons/Social_Media_Icons/Apogee-website-facebook.png';">...>


<!--Twitter-->
<a target="_blank" href="https://twitter.com/apogeeITS"><img src="http://cdn2.hubspot.net/hubfs/492950/Apogee/Icons/Social_Media_Icons/Apogee-website-twitter.png" alt="twitter"height="30px" width="30px"
onmouseover="this.src='http://cdn2.hubspot.net/hubfs/492950/Apogee/Icons/Social_Media_Icons/Apogee-website-twitter-hover.pn...';"
onmouseout="this.src='http://cdn2.hubspot.net/hubfs/492950/Apogee/Icons/Social_Media_Icons/Apogee-website-twitter.png';"><...>


<!--Linkedin-->
<a target="_blank" href="https://www.linkedin.com/company/apogee-it-services"><img src="http://cdn2.hubspot.net/hubfs/492950/Apogee/Icons/Social_Media_Icons/Apogee-website-linkedin.png" alt="linkedin"height="30px" width="30px"
onmouseover="this.src='http://cdn2.hubspot.net/hubfs/492950/Apogee/Icons/Social_Media_Icons/Apogee-website-linkedin-hover.p...';"
onmouseout="this.src='http://cdn2.hubspot.net/hubfs/492950/Apogee/Icons/Social_Media_Icons/Apogee-website-linkedin.png';">...>

 

but when i hover the icons, the image does not change.

 

It used to work before but i dont know what happened.

This is the URL: https://www.apogeeitservices.com

 

Thanks!

 

0 Votes
2 Solutions acceptées
ndwilliams3
Solution
Conseiller clé

Help with Social Media Hover

Résolue

I took a look and your mouseover function is still working. However, the Responsive image srcset is overriding the image that is displaying. I'm not sure of the best way to fix this with Javascript outside of also including a function to change the srcset images to http://cdn2.hubspot.net/hubfs/492950/Apogee/Icons/Social_Media_Icons/Apogee-website-facebook-hover.p.... Using CSS vs onmouseover function should also solve the issue.

Voir la solution dans l'envoi d'origine

Ty
Solution
HubSpot Employee
HubSpot Employee

Help with Social Media Hover

Résolue

Hi Mariana!

 

As ndwilliams3 mentioned, this is easily done with CSS, some benefits are load time, and the fact that you won't need to rely on JS to make sure these hovers work correctly. I quickly built out an example that matches the one you use on the homepage. Feel free to try it out 🙂

 

HTML

<!--Facebook-->
<a target="_blank" class="social-icons facebook" href="https://www.facebook.com/apogeeITservices">
</a>

<!--Twitter-->
<a target="_blank" class="social-icons twitter" href="https://twitter.com/apogeeITS">
</a>

<!--Linkedin-->
<a target="_blank" class="social-icons linkedin" href="https://www.linkedin.com/company/apogee-it-services">
</a>

CSS

.social-icons{
  width:45px;
  height:40px;
  display:block;
  float:left;
  background-repeat:no-repeat !important;
}

.facebook{  background:url("http://cdn2.hubspot.net/hubfs/492950/Apogee/Icons/Social_Media_Icons/Apogee-website-facebook.png");
}

.facebook:hover{
background:url("http://cdn2.hubspot.net/hubfs/492950/Apogee/Icons/Social_Media_Icons/Apogee-website-facebook-hover.png");
}


.twitter{  background:url("http://cdn2.hubspot.net/hubfs/492950/Apogee/Icons/Social_Media_Icons/Apogee-website-twitter.png");
}

.twitter:hover{  background:url("http://cdn2.hubspot.net/hubfs/492950/Apogee/Icons/Social_Media_Icons/Apogee-website-twitter-hover.png");
}


.linkedin{
background:url("http://cdn2.hubspot.net/hubfs/492950/Apogee/Icons/Social_Media_Icons/Apogee-website-linkedin.png");
}

.linkedin:hover{  background:url("http://cdn2.hubspot.net/hubfs/492950/Apogee/Icons/Social_Media_Icons/Apogee-website-linkedin-hover.png");
}

Also, here is a JSFiddle where you can see it in action!

 

I hope this helps, let me know if you have any questions!

 

-- Ty

Voir la solution dans l'envoi d'origine

5 Réponses
subin
Contributeur de premier rang | Partenaire solutions Gold
Contributeur de premier rang | Partenaire solutions Gold

Help with Social Media Hover

Résolue

Hi, 

For this type of elements try to use icons (eg: font awsome),

http://fontawesome.io/icons/    So it will be easy to add css

Smiley heureux

 

Thanks

Ty
Solution
HubSpot Employee
HubSpot Employee

Help with Social Media Hover

Résolue

Hi Mariana!

 

As ndwilliams3 mentioned, this is easily done with CSS, some benefits are load time, and the fact that you won't need to rely on JS to make sure these hovers work correctly. I quickly built out an example that matches the one you use on the homepage. Feel free to try it out 🙂

 

HTML

<!--Facebook-->
<a target="_blank" class="social-icons facebook" href="https://www.facebook.com/apogeeITservices">
</a>

<!--Twitter-->
<a target="_blank" class="social-icons twitter" href="https://twitter.com/apogeeITS">
</a>

<!--Linkedin-->
<a target="_blank" class="social-icons linkedin" href="https://www.linkedin.com/company/apogee-it-services">
</a>

CSS

.social-icons{
  width:45px;
  height:40px;
  display:block;
  float:left;
  background-repeat:no-repeat !important;
}

.facebook{  background:url("http://cdn2.hubspot.net/hubfs/492950/Apogee/Icons/Social_Media_Icons/Apogee-website-facebook.png");
}

.facebook:hover{
background:url("http://cdn2.hubspot.net/hubfs/492950/Apogee/Icons/Social_Media_Icons/Apogee-website-facebook-hover.png");
}


.twitter{  background:url("http://cdn2.hubspot.net/hubfs/492950/Apogee/Icons/Social_Media_Icons/Apogee-website-twitter.png");
}

.twitter:hover{  background:url("http://cdn2.hubspot.net/hubfs/492950/Apogee/Icons/Social_Media_Icons/Apogee-website-twitter-hover.png");
}


.linkedin{
background:url("http://cdn2.hubspot.net/hubfs/492950/Apogee/Icons/Social_Media_Icons/Apogee-website-linkedin.png");
}

.linkedin:hover{  background:url("http://cdn2.hubspot.net/hubfs/492950/Apogee/Icons/Social_Media_Icons/Apogee-website-linkedin-hover.png");
}

Also, here is a JSFiddle where you can see it in action!

 

I hope this helps, let me know if you have any questions!

 

-- Ty

mariana_pic
Contributeur | Partenaire solutions Platinum
Contributeur | Partenaire solutions Platinum

Help with Social Media Hover

Résolue

I just saw this!

I've created something very similar!!

 

Thank you!!!

ndwilliams3
Solution
Conseiller clé

Help with Social Media Hover

Résolue

I took a look and your mouseover function is still working. However, the Responsive image srcset is overriding the image that is displaying. I'm not sure of the best way to fix this with Javascript outside of also including a function to change the srcset images to http://cdn2.hubspot.net/hubfs/492950/Apogee/Icons/Social_Media_Icons/Apogee-website-facebook-hover.p.... Using CSS vs onmouseover function should also solve the issue.

mariana_pic
Contributeur | Partenaire solutions Platinum
Contributeur | Partenaire solutions Platinum

Help with Social Media Hover

Résolue

Thank you!

I decided to go with the CSS solution!

Its working now!

 

0 Votes