Font-awesome: Space between name and icon with JavaScript

Created on 16 Apr 2019  路  6Comments  路  Source: FortAwesome/Font-Awesome

Before i used CSS FortAwesome5 and when i change CSS to JS space between name and icon disappear , and   not work .

JS
after

CSS
Screenshot from 2019-04-16 16-41-54

waiting for feedback

All 6 comments

Hi!

Thanks for being part of the Font Awesome Community.

I cannot replicate it with my reduced test case
CSS: https://jsfiddle.net/tagliala/6rhmuj25/16/
SVG: https://jsfiddle.net/tagliala/we7gtcvk/20/

but.. I advise you to avoid spaces and   for layout purposes.

Also, since icons have not the same width by design, I also suggest you to use the fa-fw class to keep icons and text vertically aligned in your use case

Demo: https://jsfiddle.net/tagliala/we7gtcvk/24/

Could you please provide a reproducible test case of your issue?

I use fa-fw but dont work.
<li> <a href="index.html"> <i class="fas fa-fw fa-tachometer-alt"></i> Dashboard</a> </li>

But in inspect element i change width for svg tag and work.
.svg-inline--fa.fa-w-18 { width: 3.125em; }
how fix this?

Could you please provide a reproducible test case?

What is not working?

Use margin-right in icon.

I use class fa-fw but not add margin enough .
https://jsfiddle.net/Fakhamatia/m80krne9/6/
Add this .svg-inline--fa{margin-right: 19px;} to main CSS and its work.
Before add JS instead of CSS i add this to main CSS li a i {margin-right: 19px;}
But this fa-fw keeps all icons and names vertically aligned in menu , i didnt know before.
I hurried up and did not read the doc well. Sorry

Ok, got it.

Don't worry, glad it helped

As @giliardgomes suggested, if fa-fw is not enough, use margin-right, but keep in mind that <i> elements will be replaced by <svg> with the SVG framework, so li a i {margin-right: 19px;} should become something like li a svg {margin-right: 19px;} or better with a custom class, so it will work with both CSS and SVG approaches

https://jsfiddle.net/9mhrvtqc/

Was this page helpful?
0 / 5 - 0 ratings

Related issues

davegandy picture davegandy  路  284Comments

open2 picture open2  路  178Comments

quxiaofeng picture quxiaofeng  路  160Comments

QuincyLarson picture QuincyLarson  路  308Comments

bhubbard picture bhubbard  路  169Comments