CMS Development

mariana_pic
Colaborador | Partner nivel Platinum
Colaborador | Partner nivel Platinum

Help with Social Media Hover

resolver

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 Me gusta
2 Soluciones aceptadas
ndwilliams3
Solución
Asesor destacado

Help with Social Media Hover

resolver

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.

Ver la solución en mensaje original publicado

Ty
Solución
HubSpot Employee
HubSpot Employee

Help with Social Media Hover

resolver

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

Ver la solución en mensaje original publicado

5 Respuestas 5
subin
Colaborador líder | Partner nivel Gold
Colaborador líder | Partner nivel Gold

Help with Social Media Hover

resolver

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

Emoticono feliz

 

Thanks

Ty
Solución
HubSpot Employee
HubSpot Employee

Help with Social Media Hover

resolver

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
Colaborador | Partner nivel Platinum
Colaborador | Partner nivel Platinum

Help with Social Media Hover

resolver

I just saw this!

I've created something very similar!!

 

Thank you!!!

ndwilliams3
Solución
Asesor destacado

Help with Social Media Hover

resolver

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
Colaborador | Partner nivel Platinum
Colaborador | Partner nivel Platinum

Help with Social Media Hover

resolver

Thank you!

I decided to go with the CSS solution!

Its working now!

 

0 Me gusta