首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >` `content:''` vs ` `content: none`

` `content:''` vs ` `content: none`
EN

Stack Overflow用户
提问于 2011-07-24 04:55:22
回答 1查看 33.2K关注 0票数 32

我读了Eric Meyer的CSS reset,看到了这个:

代码语言:javascript
复制
blockquote:before, blockquote:after,
q:before, q:after {
    /* ? */ content: '';
    /* ? */ content: none;
}

我假设一些浏览器支持content: ''和一些content: none,是这样的吗?哪种浏览器支持哪种浏览器?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2011-07-24 05:00:19

Meyer将该版本的blockquote/q重置样式归功于Paul Chaplin。

卓别林关于这个主题的post包含以下样式块,并进行了有帮助的注释。

代码语言:javascript
复制
blockquote, q
{
    quotes: none;
}

/*
Safari doesn't support the quotes attribute, so we do this instead.
*/
blockquote:before, blockquote:after, q:before, q:after
{
    /*
    CSS 2; used to remove quotes in case "none" fails below.
    */
    content: "";
    /*
    CSS 2.1; will remove quotes if supported, and override the above.
    User-agents that don't understand "none" should ignore it, and
    keep the above value. This is here for future compatibility,
    though I'm not 100% convinced that it's a good idea...
    */
    content: none;
}

简而言之:大多数浏览器的当前版本只支持quotes: none样式,这样就不需要使用:before:after选择器了。例外的是Safari/WebKit,它不尊重quotes: none。解决这个问题的下一种方法是使用:before/:after伪元素,但在撰写本文时,WebKit也不支持content: none,因此需要content: ""

然而,这篇文章是在2008年发布的,在当前WebKit浏览器(Safari5.1和Chrome12)上运行的quick test显示,quotes: none在这两种浏览器上都可以很好地工作。由于某些原因,content: none bug against WebKit仍然是打开的,而bug for the quotes property最近刚刚关闭。

所以,长话短说,额外的样式似乎是为了支持旧版本的Safari (可能还有Chrome)。要确切地确定它们何时获得支持有点困难,但所有浏览器的当前版本似乎都能很好地处理quotes: none (和content: none)。

票数 36
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/6803250

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档