Help with Social Media Hover

SOLVE
mariana_pic
Participant | Platinum Partner

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 Upvotes
2 Accepted solutions

Accepted Solutions
ndwilliams3
Solution
Key Advisor

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.

View solution in original post

Ty
Solution
HubSpot Employee
HubSpot Employee

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

View solution in original post

5 Replies 5
ndwilliams3
Solution
Key Advisor

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.

View solution in original post

mariana_pic
Participant | Platinum Partner

Thank you!

I decided to go with the CSS solution!

Its working now!

 

0 Upvotes
Ty
Solution
HubSpot Employee
HubSpot Employee

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

View solution in original post

mariana_pic
Participant | Platinum Partner

I just saw this!

I've created something very similar!!

 

Thank you!!!

subin
Top Contributor

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 Happy

 

Thanks