Vertical align font awesome icon with text within <li>

Cirnu

I have a list that uses font awesome, hence its class is fa-ul :

<ul class='fa-ul'>
      <li class='dept'><i class='fa-li fa fa-stop'></i><span>Management</span></li>
      <li class='dept'><i class='fa-li fa fa-stop'></i><span>Something else</span></li>
</ul>

The associated CSS is :

li {
    font-size : 2em;
    margin: 1em 0;
}

I'd like the text and the stop-square to be vertically aligned. So far, it is not the case :

See screenshot:

See screenshot

I've tried to wrap the fa-icon and the text in a <div> element with vertical-align property set to middle, without success. Thanks for helping me.

kukkuz

Use inline-blocks and do vertical-align: middle to make it right.

li {
    font-size : 2em;
    margin: 1em 0;
}

li > *{
  display: inline-block;
  vertical-align: middle;
  }
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css" rel="stylesheet" integrity="sha384-T8Gy5hrqNKT+hzMclPo118YTQO6cYprQmhrYwIiQ/3axmI1hQomh7Ud2hPOy8SP1" crossorigin="anonymous">

<ul class='fa-ul'>
      <li class='dept'><i class='fa-li fa fa-stop'></i><span>Management</span></li>
      <li class='dept'><i class='fa-li fa fa-stop'></i><span>Something else</span></li>
</ul>

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Append Font Awesome Icon to <li>

From Dev

CSS3 transition within Awesome Icon Font and Text Hover

From Dev

Position font awesome span icon above text within an anchor

From Dev

Font Awesome icon behind text

From Dev

Font Awesome icon behind text

From Dev

How to align list Items with font-awesome icon next line text?

From Dev

vertical-align within an <li> tag

From Java

Font Awesome icon inside text input element

From Dev

How to position text over Font Awesome icon?

From Dev

Overlapping a font awesome icon inside a text field

From Dev

Font awesome icon and text in input submit button?

From Dev

How to insert font awesome icon into text input?

From Dev

Center text above font awesome icon?

From Dev

How to position an Awesome Font Icon after a text

From Dev

No Font-Awesome icons on buttons will vertical-align

From Dev

Vertical align text alongside SVG icon

From Dev

css vertical align img and text (multiline) in <li>

From Dev

css vertical align img and text (multiline) in <li>

From Dev

vertically align font awesome icon in td with variable height

From Dev

how can I align font awesome icon in bootstrap button?

From Dev

how can I align font awesome icon in bootstrap button?

From Dev

Bootstrap 4 align Font Awesome icon horizontally and vertically

From Java

How to vertically align text with icon font?

From Dev

Font awesome icon placed top right corner of input within table

From Dev

Vertically align image with text within <li>

From Dev

Make text stay within vertical progress bar + vertical align: center

From Dev

Font Awesome Icon Alignment

From Dev

Font Awesome icon in React

From Dev

Font Awesome Icon Alignment

Related Related

HotTag

Archive