gpt4 book ai didi

html - Font Awesome 垂直图标对齐

转载 作者:太空宇宙 更新时间:2023-11-03 22:58:07 24 4
gpt4 key购买 nike

为什么 vertical-align: middle; 没有将图标对齐到标题的中间?

    .custom {
color: white;
vertical-align: middle;
}
.header {
width: 100%;
height: 40px;
background: rgb(40,40,40);
}
<link href="http://netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet"/>
<div class="header">
<i class="fa fa-facebook custom" aria-hidden="true"></i>
<i class="fa fa-twitter custom" aria-hidden="true"></i>
<i class="fa fa-instagram custom" aria-hidden="true"></i>
<i class="fa fa-google-plus custom" aria-hidden="true"></i>
</div>

最佳答案

如今,垂直居中对齐的最佳方式是使用 flexbox。另见:

https://css-tricks.com/snippets/css/a-guide-to-flexbox/

https://philipwalton.github.io/solved-by-flexbox/demos/vertical-centering/

.custom {
color: white;
vertical-align: middle;
}

.header {

display:flex;
align-items: center;

width: 100%;
height: 40px;
background: rgb(40,40,40);
}
<link href="http://netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet"/>
<div class="header">
<i class="fa fa-facebook custom" aria-hidden="true"></i>
<i class="fa fa-twitter custom" aria-hidden="true"></i>
<i class="fa fa-instagram custom" aria-hidden="true"></i>
<i class="fa fa-google-plus custom" aria-hidden="true"></i>
</div>

关于html - Font Awesome 垂直图标对齐,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37511546/

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