Skip to content Skip to sidebar Skip to footer

Make Font Awesome Icons In A Circle Border With Right 1:1 Ratio

In some case, if the ratio of the icon is not 1:1, the border is not a circle anymore. Here's an example: I'm currently using: HTML: .socials a(href='#')
a/* or selector a .fa */
  {  
  font-size:3em;
  border-radius: 50%;
  border: solid white;
  color: white;
  line-height: 2em;
  width: 2em;
  height: 2em;
  text-align: center;
  display: inline-block;
    transition:0.5s;
}
/* demo purpose */a:hover {font-size:2em}
.fa {
/* optionnal vertical-align: middle;*/
}
body {
  background: #333
}
<linkhref="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css"rel="stylesheet" /><ahref="#"><iclass="fa fa-facebook"></i></a><ahref="#"><iclass="fa fa-twitter"></i></a><ahref="#"><iclass="fa fa-google"></i></a>

Solution 2:

set a fixed width and height, and use text-align:center

i {
  border-radius: 50%;
  border: solid black;
  padding: 10px;
  width:16px;
  height: 16px;
  text-align:center
}
<linkhref="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css"rel="stylesheet"/><iclass="fa fa-facebook"></i><iclass="fa fa-twitter"></i><iclass="fa fa-google"></i>

Solution 3:

border-radius in the percent calculated as a percent of width and height different. try 50px for exam.

div {
  margin: .3em;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2em;
  color: white;
}
.pc {
  width: 200px;
  height: 80px;
  background-color: blue;
  border-radius: 50%;
}
.px {
  width: 200px;
  height: 80px;
  background-color: blue;
  border-radius: 50px;
}
<divclass="pc">%</div><divclass="px">px</div>

Solution 4:

To achieve it while keeping the icon with its aspect ratio you need to assign a container to the icon with a 1:1 ratio (same width as height).

i.fa-facebook {
  padding: 10px;
  color: white;
}

.border {
  border-radius: 50%;
  border: solid white;
}

a.icon_container {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: solid white;
  text-align: center;
  float: left;
}

body {
  background: black;
}
<linkhref="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css"rel="stylesheet"/><iclass="fa fa-facebook border"></i><ahref="#"class="icon_container border"><iclass="fa fa-facebook"></i></a>

Post a Comment for "Make Font Awesome Icons In A Circle Border With Right 1:1 Ratio"