duddosai duddosai - 23 days ago 6
CSS Question

Combine two Font Awesome icons

I'm trying to combine two Font Awesome icons, to create a stack. I'm trying to merge

fa-calendar
and
fa-clock-o
icons. This because, I need an icon for date-time.

So, in order to combine them, I tried this:

HTML

<span class="icon-stack">
<i class="fa fa-calendar icon-stack-3x"></i>
<i class="fa fa-clock-o icon-stack-1x"></i>
</span>


CSS

.icon-stack {
position: relative;
display: inline-block;
width: 2em;
height: 5em;
line-height: 4em;
vertical-align: middle;
}
.icon-stack-1x,
.icon-stack-2x,
.icon-stack-3x {
position: absolute;
left: 0;
width: 100%;
text-align: center;
}
.icon-stack-1x {
line-height: inherit;
}
.icon-stack-2x {
font-size: 1.5em;
}
.icon-stack-3x {
font-size: 2em;
}


This is what I get as a result.

enter image description here

But, I want to bring a little bit to right. I don't know how to do that? What can I do to bring it a bit towards right?

Answer

Well, as you have done your own CSS for position you just need to set the text-align to right, like this:

.icon-stack-3x {
  position: absolute;
  left: 0;
  width: 100%;
  text-align: right;
}

Here is a working example