CMS Development

mariana_pic
投稿者 | Platinum Partner
投稿者 | Platinum Partner

Help with Social Media Hover

解決

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 いいね!
2件の承認済みベストアンサー
ndwilliams3
解決策
キーアドバイザー

Help with Social Media Hover

解決

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.

元の投稿で解決策を見る

Ty
解決策
HubSpot Employee
HubSpot Employee

Help with Social Media Hover

解決

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

元の投稿で解決策を見る

5件の返信
subin
トップ投稿者 | Gold Partner
トップ投稿者 | Gold Partner

Help with Social Media Hover

解決

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

スマイリー ハッピー

 

Thanks

Ty
解決策
HubSpot Employee
HubSpot Employee

Help with Social Media Hover

解決

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
投稿者 | Platinum Partner
投稿者 | Platinum Partner

Help with Social Media Hover

解決

I just saw this!

I've created something very similar!!

 

Thank you!!!

ndwilliams3
解決策
キーアドバイザー

Help with Social Media Hover

解決

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
投稿者 | Platinum Partner
投稿者 | Platinum Partner

Help with Social Media Hover

解決

Thank you!

I decided to go with the CSS solution!

Its working now!

 

0 いいね!