这是我的代码:
.fa-caret-down{
margin-top: 3px;
padding-top:3px;
line-height: 3;
}

<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css" rel="stylesheet"/>
<div><span>something</span> <i class="fa fa-caret-down" aria-hidden="true"></i></div>
&#13;
如您所见,padding
或margin
或line-height
都没有达到预期的效果。这是预期的结果:
我怎么能得到它?
注意:根据我的实际代码,我不应该将position: absolute;
用于<i>
元素。
答案 0 :(得分:3)
margin
/ padding
/ line-height
正常运作,您只需将vertical-align:top
添加到span
span{
vertical-align:top;
}
.fa-caret-down{
margin-top: 3px;
padding-top:3px;
}
&#13;
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css" rel="stylesheet"/>
<div><span>something</span> <i class="fa fa-caret-down" aria-hidden="true"></i></div>
&#13;
答案 1 :(得分:1)
以下是可行的更改
.fa-caret-down{
top: 6px;
position : relative;
}
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css" rel="stylesheet"/>
<div><span>something</span> <i class="fa fa-caret-down" aria-hidden="true"></i></div>