我正在尝试通过 icomoon 字体通过菜单栏将图标添加到 wordpress 中我的文本链接的左侧。我正在使用从 icomoon 下载时附带的 css。我已经在 WP 管理区域的菜单选项区域中添加了类。图标(字体)确实显示在“li”元素上,但我希望将它们添加到“a”元素中。仅供引用,添加字体的类使用 :before 选择器。这是 css 的摘录:
[class^="icon-"]:before, [class*=" icon-"]:before {
font-family: 'icomoon';
font-style: normal;
speak: none;
font-weight: normal;
line-height: 1;
-webkit-font-smoothing: antialiased;
color: $white;
}
.icon-home:before {
content: "\68";
}
最佳答案
试试这个。这是我使用的方法。
HTML
<h3 class="title-style">
<a href="#">
<span aria-hidden="true" data-icon="[insert number from icomoon]";></span>TITLE
</a>
</h3>
CSS
.title-style > a{
font-family: 'font name';
}
[data-icon]::before {
font-family: 'icomoon';
content: attr(data-icon);
speak: none;
}
关于css - icomoon 字体和 wordpress 导航菜单,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14548436/