• Aufgepasst:

    HubSpot-Erfahrungen teilen & Amazon-Gutscheine erhalten

    Mehr erfahren

CMS Development

mariana_pic
Mitwirkender/Mitwirkende | Platinum Partner
Mitwirkender/Mitwirkende | Platinum Partner

Help with Social Media Hover

lösung

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 Akzeptierte Lösungen
ndwilliams3
Lösung
Autorität

Help with Social Media Hover

lösung

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.

Lösung in ursprünglichem Beitrag anzeigen

Ty
Lösung
HubSpot Employee
HubSpot Employee

Help with Social Media Hover

lösung

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

Lösung in ursprünglichem Beitrag anzeigen

5 Antworten
subin
Stratege/Strategin | Gold Partner
Stratege/Strategin | Gold Partner

Help with Social Media Hover

lösung

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 (fröhlich)

 

Thanks

Ty
Lösung
HubSpot Employee
HubSpot Employee

Help with Social Media Hover

lösung

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
Mitwirkender/Mitwirkende | Platinum Partner
Mitwirkender/Mitwirkende | Platinum Partner

Help with Social Media Hover

lösung

I just saw this!

I've created something very similar!!

 

Thank you!!!

ndwilliams3
Lösung
Autorität

Help with Social Media Hover

lösung

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
Mitwirkender/Mitwirkende | Platinum Partner
Mitwirkender/Mitwirkende | Platinum Partner

Help with Social Media Hover

lösung

Thank you!

I decided to go with the CSS solution!

Its working now!

 

0 Upvotes