css - 如何将 Google 图标字体添加到伪 :before

标签 css

我使用的是 Google 的 Material Design 图标字体。

但是我想将一个 fone 叠加在另一个之上。这个想法是添加一个 :before 或 :after 元素并将其设置为如下样式:

.material-icons:before
{
    position:absolute;
    content:"";
    color:@accent-color;
    font-size:2.4rem;
}

但是,我不确定如何合并:;进入 content 属性 - 我尝试了多种方法以及在 CSS 技巧上使用转换器(这似乎不起作用)。

感谢任何帮助。

最佳答案

在 CSS 中,要指定一个字符,您将在 HTML 中使用 & 转义符指定,例如; ,必须使用\转义,例如content: "\9999"

.material-icons:before {
     position: absolute;
     content: "\E84E";
     color: #882288;
     font-size: 2.4rem;
}

要显式结束转义字符,请使用另一个 \,例如 content: "\E84E\Hello World";

关于css - 如何将 Google 图标字体添加到伪 :before,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31156787/

相关文章:

html - 文本中间的水平线

html - 视差导航菜单慢速效果

html - Rails iframe 标签未 100% 填充整个页面

c# - 固定顶部导航栏覆盖按钮

html - 覆盖蒙版偏离中心

css - Font-face 嵌入式字体在 Windows 7 浏览器中看起来很模糊

HTML 复选框 : can you have a hidden checkbox that is still working normally (being set/unset via a label)?

html - 根据分辨率折叠 div

html - 客户端 CSS 属性覆盖我们的 html 选项卡部分

javascript - 如何从 DOM 获取水平尺寸?