Currently in the process of designing some stack icons, I've come across several discussions that suggest the following approach -
i {
position: relative;
}
i:before {
content: "\f099";
position: absolute;
font-size: 1.5em;
}
i:after {
content: "\f096";
position: absolute;
font-size: 2.1em;
left: 0;
}
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<i class="fa"></i>
The issue arises when multiple icons are involved,
<i class="fa"></i>
<i class="fa"></i>
In this case, both icons end up stacking on top of each other.
A different solution to this problem is as follows:
i {
position: relative;
}
i:before {
content: "\f099";
font-size: 1.5em;
}
i:after {
content: "\f096";
position: absolute;
font-size: 2.1em;
left: 0;
}
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<i class="fa"></i>
Upon removing position: absolute
from i:before
and retaining it with position:absolute
along with left:0
in i:after
, the icons function as desired.
The concern at hand is whether this new solution is indeed correct and what led to including position:absolute
in i:before
in the previous solutions?