CSS 如何在伪类之前和之后删除或禁用?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11649295/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-30 04:35:15  来源:igfitidea点击:

How to remove or disable before and after pseudo classes?

csscss-spritespseudo-class

提问by jilseego

This seems very trivial but I couldn't figure it out. Simply overriding it with display:nonedoesn't work on IE8.

这看起来很微不足道,但我无法弄清楚。简单地覆盖它display:none在 IE8 上不起作用。

#selector::after {
    display: none;
}

I am modifying a theme that's using before and after pseudo classes to add image sprites.

我正在修改一个在伪类之前和之后使用的主题来添加图像精灵。

回答by bugwheels94

Use colon only one time

只使用一次冒号

#selector:after {
    display: none;
}

回答by simhumileco

The W3C specyficationsays that in CSS3all pseudo-elementslike ::beforeand ::aftermust use the double-colonsyntax, but:

W3C specyfication说,在CSS3所有伪元素喜欢::before::after必须使用双冒号语法,但是:

For compatibility with existing style sheets, user agents must also accept the previous one-colon notation for pseudo-elements introduced in CSS levels 1 and 2 (namely, :first-line, :first-letter, :beforeand :after).

对于与现有的样式表的兼容性,用户代理也必须接受在CSS水平引入伪元素前一个冒号符号1和2(即,:first-line:first-letter:before:after)。

So in your case use one-colon notation.

因此,在您的情况下,请使用单冒号表示法