For both elements occupy the same place, use position: absolute
on the #plus
icon and it will overlap the first one, but you must put them inside the same container, it can be span
because it does not change the layout . But span
also needs position: relative
:
span.icone{
position: relative;
background: red; /* apenas para mostrar a área ocupada pelo span */
}
#plus {
transform: rotate(90deg);
position: absolute;
top: 0;
left: 0;
}
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.3.1/css/all.css">
<span class="icone">
<i class="fas fa-minus"></i>
<i id="plus" class="fas fa-minus"></i>
</span>
In this case you do not need to reposition one of the elements with translate
.
For Safari, you need to add the -webkit-
prefix to transform
:
#plus {
-webkit-transform: rotate(90deg);
transform: rotate(90deg);
}
Alternative with native classes
You can use native component classes to stack the two icons by doing only the second CSS path rotation. Following the same example above, putting the icons inside a span
, put the fa-stack
class in the container and the fa-stack-1x
class in each icon ( 1x
is the normal size of the icon):
.rot {
transform: rotate(90deg);
}
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.3.1/css/all.css">
<span class="fa-stack">
<i class="fas fa-minus fa-stack-1x"></i>
<i class="fas fa-minus fa-stack-1x rot"></i>
</span>