gpt4 book ai didi

twitter-bootstrap - 如何将图标移动到这个社交按钮的中心?

转载 作者:行者123 更新时间:2023-11-28 16:19:55 24 4
gpt4 key购买 nike

我正在尝试将 Font Awesome 图标在其圆形背景中垂直和水平移动到中心。但每次要么在左边,要么在顶部,要么在底部。
如何固定这些图标并移动到中心?

这是代码(因为它在页脚中,所以我在 CSS 中添加了额外的行):

     
.page-footer {
background-color:#222222;
padding: 0 40px;
text-align: center;
}
.page-footer a {
font-size:14px;
color:#ffffff;
}

ul.social-buttons {
text-align: center;
justify-content: center;
margin-top:40px;
}

ul.social-buttons li a {
font-size: 35px;
line-height: 50px;
display: block;
width: 70px;
height: 70px;
-webkit-transition: all 0.3s;
transition: all 0.3s;
color: #222222;
border-radius: 100%;
outline: none;
background-color: #ffffff;
border:5px solid #fed136;
}

ul.social-buttons li a:active, ul.social-buttons li a:focus, ul.social-buttons li a:hover {
background-color: #fed136;
}
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.5.0/css/all.css" integrity="sha384-B4dIYHKNBt8Bc12p+WXckhzcICo0wtJAoU8YZTY5qE0Id1GSseTk6S+L3BlXeVIU" crossorigin="anonymous">
<div class="col-md-4">

<ul class="list-inline social-buttons">
<li class="list-inline-item">
<a href="#">
<i class=" fab fa-linkedin-in"></i>
</a>
</li>
<li class="list-inline-item">
<a href="#">
<i class="fab fa-google-plus-g"></i>
</a>
</li>
<li class="list-inline-item">
<a href="#">
<i class="fab fa-facebook-f"></i>
</a>
</li>
<li class="list-inline-item">
<a href="#">
<i class="fab fa-twitter"></i>
</a>
</li>
</ul>
</div>

最佳答案

您可以在 i 元素上使用 vertical-align:middle。它们是 inline-block 元素,它们将在其容器内垂直对齐。无需添加特定的行高或边距等。

见下文

.page-footer {
background-color: #222222;
padding: 0 40px;
text-align: center;
}

.page-footer a {
font-size: 14px;
color: #ffffff;
}

ul.social-buttons {
text-align: center;
justify-content: center;
margin-top: 40px;
}

ul.social-buttons li a {
font-size: 35px;
line-height: 50px;
display: block;
width: 70px;
height: 70px;
-webkit-transition: all 0.3s;
transition: all 0.3s;
color: #222222;
border-radius: 100%;
outline: none;
background-color: #ffffff;
border: 5px solid #fed136;
}

ul.social-buttons li a:active,
ul.social-buttons li a:focus,
ul.social-buttons li a:hover {
background-color: #fed136;
}

ul.social-buttons li a i {
vertical-align:middle;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet"/>
<link href="https://use.fontawesome.com/releases/v5.5.0/css/all.css" rel="stylesheet"/>
<div class="col-md-4">
<ul class="list-inline social-buttons">
<li class="list-inline-item">
<a href="#">
<i class=" fab fa-linkedin-in"></i>
</a>
</li>
<li class="list-inline-item">
<a href="#">
<i class="fab fa-google-plus-g"></i>
</a>
</li>
<li class="list-inline-item">
<a href="#">
<i class="fab fa-facebook-f"></i>
</a>
</li>
<li class="list-inline-item">
<a href="#">
<i class="fab fa-twitter"></i>
</a>
</li>
</ul>
</div>

另一种选择是

ul.social-buttons li a {
display: flex;
align-items: center;
justify-content: center;
}

关于twitter-bootstrap - 如何将图标移动到这个社交按钮的中心?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53535749/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com