如何使用此字体真棒图标作为列表来修复缩进以显示优势?
这是我的HTML:
<p> <i class="f_item_tick fa fa-check"></i>
No upfront payment is required to access the solution. A Nominee and Supervisory fee are both payable once the solution is active. These are taken from the monthly contributions you pay into.
</p>
除了以下内容之外,我没有应用太多的CSS来使绿色标记:
.f_item_tick {
color: #00a885;
font-size:1.8rem;
}
理想情况下我想要它,以便payable
与No
一致(见图片)
答案 0 :(得分:2)
如果您不想更改标记,最简单的方法是提供<p>
元素position:relative
并将带有position:absolute
的图标放在填充区域内:
p {
padding-left: 2em;
position: relative;
}
p .fa {
position: absolute;
left: 0;
}
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" />
<p>
<i class="f_item_tick fa fa-check"></i>
No upfront payment is required to access the solution. A Nominee and Supervisory fee are both payable once the solution is active. These are taken from the monthly contributions you pay into.
</p>
<p>
元素) 。<p>
元素。另一种选择是将图标放在其父图标之外,并将其与父display:flex;
.flex-item {
display: flex;
}
.flex-item .fa {
padding: 1em 1em 0 0;
}
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet"/>
<div class="flex-item">
<i class="f_item_tick fa fa-check"></i>
<p> No upfront payment is required to access the solution. A Nominee and Supervisory fee are both payable once the solution is active. These are taken from the monthly contributions you pay into. </p>
</div>
另一种选择是让您的text-indent
负值等于margin-left
+ padding-left
属性的总和。您还需要将margin + padding sum应用于<i>
元素:
p {
text-indent: -2em;
margin-left: 1em;
padding-left: 1em;
}
p .fa {
margin-left: 1.5em;
padding-left: 0.5em;
}
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet"/>
<p>
<i class="fa fa-check"></i>No upfront payment is required to access the solution. A Nominee and Supervisory fee are both payable once the solution is active. These are taken from the monthly contributions you pay into.
</p>
答案 1 :(得分:1)
考虑使用Font Awesome列表项实用程序类,.e.g fa-ul
和fa-li
参考:Font Awesome Examples - List Icons
代码段示范:
.f_item_tick {
color: #00a885;
font-size: 1.8rem;
}
<link rel="stylesheet" href="https://netdna.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.css">
<ul class="fa-ul">
<li><i class="fa-li f_item_tick fa fa-check fa-fw"></i> No upfront payment is required to access the solution. A Nominee and Supervisory fee are both payable once the solution is active. These are taken from the monthly contributions you pay into. </li>
</ul>
答案 2 :(得分:0)
你只需要这个css:
.f_item_tick {
color: #00a885;
font-size:1.8rem;
display: block;
float: left;
}
&#13;
您还可以添加padding-right: 10px;
。