html - 是否可以在 css 内容中一个一个地使用两个图标

标签 html css font-awesome

我有一个像下面这样的CSS类

.fa-unsorted:before, .fa-sort:before {
    content: '\e9c2';
    margin-top: -10px;
    color: #999999;
    font-family: 'icomoon';
}

显示如下

enter image description here

我想要的是也包括 \e9c1 但它应该显示在 \e9c2 下面。

对于上下文,我正在使用一个库,其中提到了用于显示排序图标的 css 类。它使用 fa-sort,在同一图标中同时具有向上和向下箭头。

enter image description here

但我使用的 icomoon 没有那种替代品。所以我需要用两个图标来显示排序。以下是我想要的

enter image description here

我尝试关注内容,但正如预期的那样,箭头彼此相邻显示。

content: '\e9c2\e9c1';

添加另一个类会很好,但我无法控制 JS 来添加新类。

最佳答案

不能向 :before 伪元素添加多个。

如果 :after 元素尚未被使用,我建议这样做:

  .fa-unsorted:before, .fa-sort:before {
        content: '\e9c2';
        margin-top: -10px;
        color: #999999;
        font-family: 'icomoon';
    }

    .fa-unsorted:after, .fa-sort:after{
        content: '\e9c1';
        margin-top: -15px;
        color: #999999;
        font-family: 'icomoon';
        right:0;
    }

关于html - 是否可以在 css 内容中一个一个地使用两个图标,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45194971/

相关文章:

javascript - 为什么<a id ="test"/>会脱离DOM链?

javascript - 我可以在 <link> 标签 href 内调用 JavaScript 函数吗?

html - 使子菜单比主菜单宽

html - 如何创建这样的元素(自适应)?

html - 将 Bootstrap 按钮与导航栏的右侧对齐

html - 如何在文本中包含小数字(文本数字)?

html - 是否有适用于 Ruby 的 HTML 浏览器渲染引擎?

html - 垂直对齐 Font Awesome 图标与 <li> 中的文本

android - 平板电脑上没有统一编码的超棒字体图标(ios 和 android)

css - bootstrap 和 font-awesome 之间的图标冲突