【问题标题】:Combine two Font Awesome icons结合两个 Font Awesome 图标
【发布时间】:2017-03-29 08:38:18
【问题描述】:

我正在尝试组合两个 Font Awesome 图标来创建一个堆栈。我正在尝试合并 fa-calendarfa-clock-o 图标。这是因为,我需要一个日期时间图标。

所以,为了将它们结合起来,我尝试了这个:

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;
}

这就是我得到的结果。

但是,我想稍微纠正一下。我不知道该怎么做?我该怎么做才能让它稍微向右一点?

【问题讨论】:

标签: css fonts font-awesome stacked


【解决方案1】:

好吧,既然你已经为位置做了自己的 CSS,你只需要将 text-align 设置为 right,如下所示:

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

Here is a working example


问题是,这看起来不太好。所以这里有几个替代方案,以防它们对你有用:Example 1Example 2

【讨论】:

  • 这行得通,我怎样才能让它更清楚?即看起来有点讨厌,让它看起来不错。有什么帮助吗?
  • @duddosai:是的,我确实尝试过,但问题是他们没有不透明的时钟图标(这是问题所在)。你为什么不试试不同的日历? maybe something like this 虽然我确实使用了绝对位置,这有时会出现问题,尤其是在不同的浏览器中。您可以尝试使用内置的堆叠类,and do it simple like this
【解决方案2】:

您可以通过添加新类使时钟向右对齐或向左填充 请看下面的代码:

.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;
    }
.right_align { padding-left:5px; }
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css">
<span class="icon-stack">
   <i class="fa fa-calendar icon-stack-3x"></i>
   <i class="fa fa-clock-o icon-stack-1x right_align"></i>
</span>

【讨论】:

  • 这有帮助,但我希望它看起来不错,就像它必须清晰一样。可以做什么?
猜你喜欢
  • 2019-12-31
  • 2021-05-04
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-06-12
  • 2019-01-24
  • 2019-05-09
相关资源
最近更新 更多