`内容:''` vs `内容:无`
我正在阅读 Eric Meyer 的 CSS Reset 并看到了这一点:
blockquote:before, blockquote:after,
q:before, q:after {
/* ? */ content: '';
/* ? */ content: none;
}
我假设某些浏览器支持 content: ''
和一些 content: none
,是这种情况吗?哪些浏览器支持哪些?
I was reading through Eric Meyer's CSS reset and saw this:
blockquote:before, blockquote:after,
q:before, q:after {
/* ? */ content: '';
/* ? */ content: none;
}
I assume that some browsers support content: ''
and some content: none
, is this the case? And which browsers support which?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
迈耶将那个版本的 blockquote/q 重置样式归功于保罗·卓别林 (Paul Chaplin)。
卓别林关于该主题的帖子包含以下样式块,并附有有用的注释。
归结起来:大多数浏览器的当前版本仅支持
quotes: none
样式,这样就无需使用:before
和:after
> 选择器。奇怪的是 Safari/WebKit,它不尊重quotes: none
。解决这个问题的下一个方法是使用:before
/:after
伪元素,但在撰写本文时,WebKit 不支持content:也没有
,因此需要content: ""
。不过,该帖子是在 2008 年发布的,并且使用当前的 WebKit 浏览器(Safari 5.1 和 Chrome 12)进行了快速测试 )表明
quotes: none
在两者上都可以正常工作。针对 WebKit 的content: none
错误 仍然存在由于某种原因,虽然 quotes 属性的错误 最近已被关闭。因此,长话短说,额外的样式似乎是为了支持旧版本的 Safari(也可能是 Chrome)。确切地确定它们何时获得支持有点困难,但所有浏览器的当前版本似乎都能很好地处理
quotes: none
(和content: none
)。Meyer credits Paul Chaplin with that version of the blockquote/q reset styles.
Chaplin's post on the subject contains the following style block, helpfully annotated.
To boil it down: current versions of most browsers simply support a
quotes: none
style, which eliminates the need to use the:before
and:after
selectors. The odd man out was Safari/WebKit, which didn't respectquotes: none
. The next way to solve this was with the:before
/:after
pseudo-elements, but at the time of that writing, WebKit didn't supportcontent: none
either, socontent: ""
was required.However, that post was in 2008, and a quick test with current WebKit browsers (Safari 5.1 and Chrome 12) shows that
quotes: none
works fine on both. Thecontent: none
bug against WebKit is still open for some reason, while the bug for the quotes property was closed fairly recently.So, long story short, the extra styles appear to be there to support older versions of Safari (and possibly Chrome). It's a little more difficult to nail down exactly when they got support, but current versions of all browsers seem to deal with
quotes: none
(andcontent: none
) just fine.