简体   繁体   English

为什么:before在我的代码中似乎只工作一次?

[英]Why does :before only seem to work once in my code?

I am using :before to display webfont icons before menu items. 我正在使用:before在菜单项之前显示webfont图标。 For some reason :before is only working on one class and is completely ignoring the other class. 由于某些原因::before只在一个类上工作,而完全忽略了另一个类。 If I change both classes on the two li's that should have icons before them to the working class name, the icon shows up. 如果我将两个li上的两个班级都更改为工作班级名称,则应该在其前面都带有图标,以显示该图标。

Ideas? 有想法吗?

Here is an example: http://jsfiddle.net/bigdmachine/erxjE/1/ 这是一个示例: http : //jsfiddle.net/bigdmachine/erxjE/1/

I'd rather update the CSS to; 我宁愿将CSS更新为;

nav#al-top-menu .log-out a:before, 
nav#al-top-menu .setting a:before {
     content: "X";
     margin-left: 15px;
     margin-right: 5px;    
     font-family: 'WebSymbolsRegular';
     font-size: 14px;
     color: blue;

} }

我认为您不能像这样在<ul>内创建“免费”伪元素,列表应仅包含列表项。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM