我如何修复字体真棒图标上的缩进?

时间:2018-01-14 00:10:28

标签: html css font-awesome indentation

如何使用此字体真棒图标作为列表来修复缩进以显示优势?

这是我的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;
}

理想情况下我想要它,以便payableNo一致(见图片)

Indentation Fix

3 个答案:

答案 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>元素) 。
    要仅将其应用于(a)特定元素,您可以将自定义类添加到所需的<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-ulfa-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:

&#13;
&#13;
.f_item_tick {
            color: #00a885;
            font-size:1.8rem;
            display: block;
            float: left;
        }
&#13;
&#13;
&#13;

您还可以添加padding-right: 10px;