html - 如何为中心的社交图标创建灰色背景?

标签 html css position icons centering

我的图标是这样的:

bad centered icon

我需要这样创建:

good centered icons

这是我的 HTML:

<aside class="social">
        <a href="https://www.instagram.com/" class="inst"><span><i class="fa fa-instagram" aria-hidden="true"></i></span></a>
        <a href="https://www.facebook.com" class="facb"><span><i class="fa fa-facebook" aria-hidden="true"></i></span></a>
        <a href="https://www.pinterest.com/" class="pint"><span><i class="fa fa-pinterest" aria-hidden="true"></i></span></a>
    </aside>

这是我的 CSS:

aside.social a {
    margin-left: 10px;
    color: #fff;
    font-size: 16px;
}

aside.social a span {
    width: 25px;
    display: inline-block;
    height: 25px;
    background-color: #aaa;
    border-radius: 40%;
}

最佳答案

你不需要两个单独的元素,你可以在你的 a 上完成这一切,里面有一个 i.fa

aside.social a {
    color: #fff;
    background: #aaa;
    margin-left: 10px;
    border-radius: 40%;
    width: 25px;
    height: 25px;
    line-height: 25px; /* vertical alignment */
    text-align: center;
    font-size: 16px;
}

关于html - 如何为中心的社交图标创建灰色背景?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44310362/

相关文章:

javascript - 从外部链接打开 Accordion 面板

javascript - 试图让我的输出显示在正文部分,格式包括页眉、正文(带背景)和页脚

css - 构建一个带有悬停和图像的快速链接 div,使其连续 4 个

javascript - 如何将变量映射到对象

javascript - 定位兄弟元素的子元素

javascript - jQuery 函数在 $(window).resize 之后仍然触发

html - css/position 主要内容 div 到登录和注册 div 的右侧

css - 我无法在 CSS 中移动我的 img 元素

jquery click 在谷歌浏览器中不起作用

html - 页脚不粘在底部