.btnup, .btndown{
display:inline-block;
font-size:20px;
background:#ddd;
border-radius:5px;
cursor:pointer;
width:25px;
line-height:30px;
height:30px;
color:#999;
text-align:center;
margin:0 5px;
}
<link href="https://use.fontawesome.com/releases/v5.3.1/css/all.css" rel="stylesheet"/>
<i class="fas fa-angle-up btnup" id='btnup'></i>
<i class="fas fa-angle-down btndown" id='btndown'></i>
如何将箭头垂直居中放置?
答案 0 :(得分:0)
您可以将FA图标放在另一个元素(该元素是灰色背景元素)中,也可以添加以下CSS属性:
height:25px;
padding-top: 5px;
基本上减少了高度,但使用了顶部填充来补偿高度,这将FA箭头图标向下压到灰色区域的中心。
答案 1 :(得分:0)
您可以添加顶部和底部填充(并从height
设置中减去这些值):
.btnup, .btndown{
display:inline-block;
font-size:20px;
background:#ddd;
border-radius:5px;
cursor:pointer;
width:25px;
line-height:30px;
height:20px;
color:#999;
text-align:center;
margin:0 5px;
padding: 5px 0 5px 0;
}
<link href="https://use.fontawesome.com/releases/v5.3.1/css/all.css" rel="stylesheet"/>
<i class="fas fa-angle-up btnup" id='btnup'></i>
<i class="fas fa-angle-down btndown" id='btndown'></i>
答案 2 :(得分:0)
line-height
被字体超棒的字体覆盖,添加!important
以使其成为您的
.btnup,
.btndown {
display: inline-block;
font-size: 20px;
background: #ddd;
border-radius: 5px;
cursor: pointer;
width: 25px;
line-height: 30px!important;
height: 30px;
color: #999;
text-align: center;
margin: 0 5px;
}
<link href="https://use.fontawesome.com/releases/v5.3.1/css/all.css" rel="stylesheet" />
<i class="fas fa-angle-up btnup" id='btnup'></i>
<i class="fas fa-angle-down btndown" id='btndown'></i>
答案 3 :(得分:0)
玩height
和padding-top
:
.btnup, .btndown{
display:inline-block;
font-size:20px;
background:#ddd;
border-radius:5px;
cursor:pointer;
width:25px;
line-height:10px;
padding-top: 5px;
height:24px;
color:#999;
text-align:center;
margin:0 5px;
}
<link href="https://use.fontawesome.com/releases/v5.3.1/css/all.css" rel="stylesheet"/>
<i class="fas fa-angle-up btnup" id='btnup'></i>
<i class="fas fa-angle-down btndown" id='btndown'></i>
答案 4 :(得分:0)
我将<span>
包裹在字符周围,并使用flexbox将其放置在中心。
.btnup,
.btndown {
display: flex;
justify-content: center; /* Horizontal alignment */
align-items: center; /* Vertical alignment */
font-size: 20px;
background: #ddd;
border-radius: 5px;
cursor: pointer;
width: 25px;
height: 30px;
color: #999;
margin: 5px;
}
<link href="https://use.fontawesome.com/releases/v5.3.1/css/all.css" rel="stylesheet" />
<span class="btnup"><i class="fas fa-angle-up"></i></span>
<span class="btndown"><i class="fas fa-angle-down"></i></span>