Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add space in between font-awesome icons in a horizontal row

Tags:

html

css

padding

Been going at this for quite some time now. I think my brain just hurts from coding for too long heres my html:

<div class="icons">
    <a href="www.twitter.com/bigmakes15"><i class="fa fa-twitter"></i></a>
    <a href="www.facebook.com/makie.michaux"><i class="fa fa-facebook"></i></a>
    <a href="www.instagram.com/bigmakes15"><i class="fa fa-instagram"></i></a>
</div>

and heres my css:

.icons a {
    display: inline;
    position: fixed;
    text-align: center;
    top: 363px;
    vertical-align: middle;
    z-index: 1000;
    height: 36px;
    width: 36px;
    text-decoration: none;
}

.fa, .fa-instagram, .fa-twitter, .fa-facebook {
     padding-right: 5px;
}

2 Answers

Your html is not right try this fix:

    <a href="www.twitter.com/bigmakes15"> <i class="fa fa-twitter"></i></a>
        <a href="www.facebook.com/makie.michaux"><i class="fa fa-facebook"></i></a>
        <a href="www.instagram.com/bigmakes15"><i class="fa fa-instagram"></i></a>

and try this css:

display: block;
margin-right: 15px;

or

 display: block;
padding-right: 15px;
like image 177
The Beast Avatar answered Oct 21 '25 23:10

The Beast


If I understand the trouble correctly, it's a combination of the html problem @jack smith caught and then either conflicting styles from somewhere else or the position: fixed - not sure what that's doing there, but in the code you've provided that's going to make them all lump together.

Note also that in your CSS you can just say .fa {...} instead of .fa, .fa-instagram, .fa-twitter, .fa-facebook {...} since those all have the fa class. In this snippet I'm using .icons i but it could just as well be .icons .fa or, if you want this to apply to all font awesome icons, just a bare .fa

.icons a {
  margin-right: 10px;/*space to the right of the blue*/ outline
  padding-right: 10px;/*between the red and blue outlines*/
  outline: 1px solid blue;
  
  /* you can add any of these */
  /*
  display: inline;
  text-align: center;
  top: 363px;
  vertical-align: middle;
  z-index: 1000;
  height: 36px;
  width: 36px;
  text-decoration: none;
  */
}
.icons i {
  padding-right: 10px;/*space before the red outline*/
  margin-right: 10px;/*also between the red and blue*/
  outline: 1px solid red;
}
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css" rel="stylesheet"/>

<div class="icons">
    <a href="www.twitter.com/bigmakes15"><i class="fa fa-twitter"></i></a>
    <a href="www.facebook.com/makie.michaux"><i class="fa fa-facebook"></i></a>
    <a href="www.instagram.com/bigmakes15"><i class="fa fa-instagram"></i></a>
</div>
like image 35
henry Avatar answered Oct 21 '25 22:10

henry



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!