2

How do I fix the indentation whilst using this font awesome icon as list to display advantages?

This is my 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>

I don't have much CSS applied besides the following to make the tick green:

.f_item_tick {
    color: #00a885;
    font-size:1.8rem;
}

Ideally I want it so the payable is in line with No (See Image)

Indentation Fix

GalAbra
  • 5,048
  • 4
  • 23
  • 42
Adam
  • 203
  • 1
  • 14

3 Answers3

3

If you don't want to change the markup, the simplest way is to give the <p> element position:relative and place the icon with position:absolute inside the padded-area:

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>
  • Please note the above code is proof-of-concept and has selectors that are too general to be used in production environment (it would affect all the <p> elements in your project).
    To only apply it to (a) particular element(s) you could add a custom class to the desired <p> element(s).

Another option is to get the icon outside of its parent and wrap them together in a parent with 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>

Yet another option is to give your text-indent a negative value equal to the sum of margin-left + padding-left properties. You'll need to apply the margin + padding sum to the <i> element, too:

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>
tao
  • 82,996
  • 16
  • 114
  • 150
  • This worked an absolute charm. Thank you very much How would I be able to implement this for a standalone `
  • `?
  • – Adam Jan 21 '18 at 20:53
  • @Adam, the principle stands: `position:absolute` positions the child relative to the closest parent with `position:relative` (which should be `
  • `, in that case). Give a `padding-left` to the `
  • ` to accommodate the icon, because now you're placing it outside the document flow.
  • – tao Jan 21 '18 at 21:06
  • Thank you! That worked a charm and I've also learnt something new (Y) – Adam Jan 21 '18 at 21:29