Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

html

css

Align font-awesome icon list item with span

A picture paints a thousand words. The text on the next line needs to align on same margin as above.

HTML:

<ul>
<li>
<p><em class="fa fa-square"></em><span>Name and surnafdddddddddddddds sdgfh dh hdfh df hdsh dfh dsfh sdfhdsfh sdf hsdfhdsfhme</span></p>
</li>
</ul>

CSS:

ul{
    display: table;
    a{
        padding-left: 10px;
    }
    span{
        padding-left: 10px;
    }
}

Update:

After @panther update:

Aligning list items with font-awesome line breaks

It is acceptable, however the fontawesome icon is now off centre.

like image 479
tread Avatar asked Dec 08 '14 14:12

tread


People also ask

How do I put text next to Font Awesome icons?

Solutions with the CSS vertical-align property If you want to make a text appear vertically aligned next to a Font Awesome icon, you can use the CSS vertical-align property set to “middle” and also, specify the line-height property. Change the size of the icon with the font-size property.

How do you put text next to icons in HTML?

in order to have text on the left or right of the image you can style your img as style="float:left"; or style="float:right"; If the text is too close to the image you can play with padding: 10px; or less.

How do I align text and logo on same line?

Entire trick is to use float: left; CSS property on the img element and all the text will automatically wrap around that image. So if you want to align text and image in the same line in HTML like this... In short that is it.

How do I align Font Awesome icons to the right?

To display Align-Right font awesome icon, add predefined class name i.e., fa-align-right (with prefix fa- ) to the i tag. And we need to add corresponding font awesome icon style for the Align-Right icon. Align-Right icon has 1 icon style i.e.,solid.


2 Answers

You can try to use font awesome's built-in solution for lists:

Use fa-ul and fa-li to easily replace default bullets in unordered lists.

font awesome's built-in solution for lists


In your case, the code will change to something like this:

<ul class="fa-ul">
  <li><i class="fa fa-square"></i><span>Name and surnafdddddddddddddds sdgfh dh hdfh df hdsh dfh dsfh sdfhdsfh sdf hsdfhdsfhme</li>
</ul>
like image 187
Adrien Be Avatar answered Oct 21 '22 16:10

Adrien Be


You are probably looking for st. like this.

em {float: left;}
a, span {margin: 0 0 0 20px; display: block;}
like image 5
pavel Avatar answered Oct 21 '22 18:10

pavel