Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Font awesome stacking square and square-o don't align

I'm trying to make this using font-awesome stacking

enter image description here

I've tried two ways, but both are ugly. The problem is that fa-square and fa-square-o are different sizes, so when you stack them, they don't line up!

my fiddle

<span class="fa fa-stack">
  <i class="fa fa-square fa-stack-1x"></i>
  <i class="fa fa-plus-square fa-stack-1x fa-inverse"></i>
  <i class="fa fa-square-o fa-stack-1x"></i>
</span>

<span class="fa fa-stack">
  <i class="fa fa-square fa-stack-1x fa-inverse"></i>
  <i class="fa fa-plus-square-o fa-stack-1x"></i>
</span>     

The result is

enter image description here

I have tried to scale down the fa-square by 86% using css. However, that is very fragile, because it depends on the browser and the zoom setting. I would like the solution to look good on both Chrome and IE11 at multiple zoom levels.

like image 440
John Henckel Avatar asked Apr 12 '17 20:04

John Henckel


People also ask

How do I stack font awesome icons?

To stack multiple icons, use the fa-stack class on the parent HTML element of the 2 icons you want to stack. Then add the fa-stack-1x class for the regularly sized icon and add the fa-stack-2x class for the larger icon. fa-inverse can be added to the icon with the fa-stack-1x to help with a knock-out looking effect.

What is FA-FW in Font Awesome?

The fa-fw class is used to set icons at a fixed width. This class is useful when different icon widths throw off alignment.

How do I make font awesome icons the same size?

Setting a Consistent Icon Width If you prefer to work with icons that have a consistent width, adding fa-fw will render each icon using the same width.

How do I set the width and height of font awesome icons?

To increase icon sizes relative to their container, use the fa-lg (33% increase), fa-2x , fa-3x , fa-4x , or fa-5x classes. If your icons are getting chopped off on top and bottom, make sure you have sufficient line-height.


1 Answers

This might help.

body {
  background-color: tan;
  font-size: 100px;
}

.fix:before {
	background: #000;
	border-radius: 20%;
	padding: 1% 5%;
}

.fix-2:before {
	background: #000;
	border-radius: 20%;
	padding: 1% 10%;
}
<link href="//maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css" rel="stylesheet"/>
<span class="fa fa-stack">
  <i class="fa fa-square fa-stack-1x fix"></i>
  <i class="fa fa-plus-square fa-stack-1x fa-inverse"></i>
</span>

<!-- Without Stacking -->
<i class="fa fa-plus-square fa-inverse fix-2"></i>
like image 53
Shaheed Mon Avatar answered Sep 28 '22 08:09

Shaheed Mon