如何正确地设计社交媒体链接(How to Style Social Media Links Correctly)

编程入门 行业动态 更新时间:2024-10-17 02:47:59
如何正确地设计社交媒体链接(How to Style Social Media Links Correctly)

链接到网站

请参阅导航菜单中的社交媒体链接。 您会注意到,当您将鼠标悬停在导航菜单中的其他链接上时,它们的字体会更改颜色,但是当您将鼠标悬停在社交媒体链接上时,它们的背景填充会增加并转移到侧面 - 这不是我的意思想。 我想要的是当你将鼠标悬停在导航菜单(#76abdc)上时,链接将填充与导航菜单中的其他链接相同的浅蓝色(#76abdc)。 例如,Facebook图标中的“f”将填充#76abdc,Twitter图标中的鸟将填充#76abdc,而LinkedIn图标中的“in”也将填充#76abdc。

我个人不知道这种风格是如何应用的(我没有开发这个部分的网站),但我确实知道它使用了字体很棒,当你强制a时你可以查看以下样式:将鼠标悬停在这些类上:

.secondary-navbar .navbar-nav > li > a:hover { background-color: #fff; border-radius: 5px; color: #1971b9; font-weight: bold; font-size: 120%; text-transform: uppercase; margin: 13px 12px 0; } .secondary-navbar .social-links > li > a:hover, .secondary-navbar .social-links > li > a:focus { margin: 13px 0 0 !important; padding: 2px 5px !important; background-color: #1971b9 !important; color: #fff!important; font-size: 180%!important; margin-right: -10px; }

我试图摆脱填充

padding: 2px 5px !important;

但这实际上似乎增加了填充(???)

在Appearance - > Widgets(顺便说一下,这是一个WordPress网站),我还可以看到“Header Social Media”的HTML如下:

<ul class="nav navbar-nav navbar-right social-links hidden-xs hidden- sm"> <li> <a href="#"> <i class="fa fa-facebook-square" aria-hidden="true"></i> </a> </li> <li> <a href="#"> <i class="fa fa-twitter-square" aria-hidden="true"></i> </a> </li> <li> <a href="#"> <i class="fa fa-linkedin-square" aria-hidden="true"></i> </a> </li> </ul>

我是否需要在CSS中更改此处或更改? 怎么样? 谢谢!

编辑 - 更新的CSS:

.secondary-navbar .social-links > li > a { /*margin: 13px 0 0;*/ margin: 13px 5px 0; padding: 2px 5px; background-color: #1a3664; color: #fff; font-size: 180%; /*margin-right:-10px;*/ /*padding: 2px 5px !important;*/ padding: 0px !important; } .secondary-navbar .social-links > li > a:hover , .secondary-navbar .social-links > li > a:focus { /*margin: 13px 0 0 !important;*/ margin: 13px 5px 0!imporant; /*padding: 2px 5px !important;*/ padding: 0px !important; background-color: #1971b9 !important; color: #fff!important; font-size: 180%!important; margin-right:-10px; }

Link To Website

Please see the social media links in the Nav Menu. You'll notice that when you hover over the other links in the Nav Menu, their font changes colors, but when you hover over the social media links, their background padding increases and they shift over to the side - this isn't what I want. All I want is for the links to fill with the same light blue color as the other links in the Nav Menu (#76abdc) as you hover over them. So for example, the "f" in the Facebook icon would be filled with #76abdc, the bird in the Twitter icon would be filled with #76abdc, and the "in" in the LinkedIn icon would also be filled with #76abdc.

I personally don't know how this style was applied (I didn't develop this part of the site), but I do know that it's using font-awesome and you can view the following styles when you force a:hover over these classes:

.secondary-navbar .navbar-nav > li > a:hover { background-color: #fff; border-radius: 5px; color: #1971b9; font-weight: bold; font-size: 120%; text-transform: uppercase; margin: 13px 12px 0; } .secondary-navbar .social-links > li > a:hover, .secondary-navbar .social-links > li > a:focus { margin: 13px 0 0 !important; padding: 2px 5px !important; background-color: #1971b9 !important; color: #fff!important; font-size: 180%!important; margin-right: -10px; }

I had tried to get rid of the padding

padding: 2px 5px !important;

But this actually seems to increase the padding (???)

In Appearance --> Widgets (this is a WordPress site, by the way), I can also see that the HTML for "Header Social Media" is as follows:

<ul class="nav navbar-nav navbar-right social-links hidden-xs hidden- sm"> <li> <a href="#"> <i class="fa fa-facebook-square" aria-hidden="true"></i> </a> </li> <li> <a href="#"> <i class="fa fa-twitter-square" aria-hidden="true"></i> </a> </li> <li> <a href="#"> <i class="fa fa-linkedin-square" aria-hidden="true"></i> </a> </li> </ul>

Do I need to change anything here or over in the CSS? How? Thank you!

EDIT - Updated CSS:

.secondary-navbar .social-links > li > a { /*margin: 13px 0 0;*/ margin: 13px 5px 0; padding: 2px 5px; background-color: #1a3664; color: #fff; font-size: 180%; /*margin-right:-10px;*/ /*padding: 2px 5px !important;*/ padding: 0px !important; } .secondary-navbar .social-links > li > a:hover , .secondary-navbar .social-links > li > a:focus { /*margin: 13px 0 0 !important;*/ margin: 13px 5px 0!imporant; /*padding: 2px 5px !important;*/ padding: 0px !important; background-color: #1971b9 !important; color: #fff!important; font-size: 180%!important; margin-right:-10px; }

最满意答案

.secondary-navbar .social-links > li > a { margin: 13px 5px 0; padding: 2px 5px; background-color: #1a3664; color: #fff; font-size: 180%; /* margin-right: -10px; */ padding: 0px !important; } and on hover social links .secondary-navbar .social-links > li > a:hover, .secondary-navbar .social-links > li > a:focus { margin: 13px 5px 0 !important; padding: 0px !important; background-color: #1971b9 !important; color: #fff!important; font-size: 180%!important; margin-right: -10px;}

尝试删除margin-right并添加padding: 0px !important对社交链接padding: 0px !important为其提供保证金

.secondary-navbar .social-links > li > a { margin: 13px 5px 0; padding: 2px 5px; background-color: #1a3664; color: #fff; font-size: 180%; /* margin-right: -10px; */ padding: 0px !important; } and on hover social links .secondary-navbar .social-links > li > a:hover, .secondary-navbar .social-links > li > a:focus { margin: 13px 5px 0 !important; padding: 0px !important; background-color: #1971b9 !important; color: #fff!important; font-size: 180%!important; margin-right: -10px;}

Try removing the margin-right and add padding: 0px !important to the social links and give margin to it

更多推荐

本文发布于:2023-08-04 23:41:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1423381.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:社交   正确地   链接   媒体   Style

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!