我知道什么是CSS重置,但最近我听说了一个叫Normalize.css的新东西

CSS和Reset CSS的区别是什么?

规范化CSS和重置CSS之间的区别是什么?

这只是CSS重置的一个新流行语吗?


当前回答

主要的区别是:

CSS重置旨在删除所有内置的浏览器样式。标准元素,如H1-6、p、strong、em等等,最终看起来完全一样,没有任何装饰。然后你应该自己添加所有的装饰。 标准化CSS旨在使内置浏览器样式在不同浏览器之间保持一致。像H1-6这样的元素将以一致的方式在浏览器中显示粗体、较大等。然后你应该只添加不同的装饰你的设计需要。

如果你的设计a)遵循排版等常见惯例,b) Normalize.css适合你的目标受众,那么使用Normalize.css而不是CSS重置将使你自己的CSS更小,写得更快。

其他回答

从它的描述来看,它似乎试图让用户代理的默认样式在所有浏览器中保持一致,而不是像重置那样去掉所有的默认样式。

保留有用的默认值,不像许多CSS重置。

主要的区别是:

CSS重置旨在删除所有内置的浏览器样式。标准元素,如H1-6、p、strong、em等等,最终看起来完全一样,没有任何装饰。然后你应该自己添加所有的装饰。 标准化CSS旨在使内置浏览器样式在不同浏览器之间保持一致。像H1-6这样的元素将以一致的方式在浏览器中显示粗体、较大等。然后你应该只添加不同的装饰你的设计需要。

如果你的设计a)遵循排版等常见惯例,b) Normalize.css适合你的目标受众,那么使用Normalize.css而不是CSS重置将使你自己的CSS更小,写得更快。

我的工作是标准化。css。

主要的区别是:

Normalize.css preserves useful defaults rather than "unstyling" everything. For example, elements like sup or sub "just work" after including normalize.css (and are actually made more robust) whereas they are visually indistinguishable from normal text after including reset.css. So, normalize.css does not impose a visual starting point (homogeny) upon you. This may not be to everyone's taste. The best thing to do is experiment with both and see which gels with your preferences. Normalize.css corrects some common bugs that are out of scope for reset.css. It has a wider scope than reset.css, and also provides bug fixes for common problems like: display settings for HTML5 elements, the lack of font inheritance by form elements, correcting font-size rendering for pre, SVG overflow in IE9, and the button styling bug in iOS. Normalize.css doesn't clutter your dev tools. A common irritation when using reset.css is the large inheritance chain that is displayed in browser CSS debugging tools. This is not such an issue with normalize.css because of the targeted stylings. Normalize.css is more modular. The project is broken down into relatively independent sections, making it easy for you to potentially remove sections (like the form normalizations) if you know they will never be needed by your website. Normalize.css has better documentation. The normalize.css code is documented inline as well as more comprehensively in the GitHub Wiki. This means you can find out what each line of code is doing, why it was included, what the differences are between browsers, and more easily run your own tests. The project aims to help educate people on how browsers render elements by default, and make it easier for them to be involved in submitting improvements.

我在一篇关于normalization .css的文章中对此进行了更详细的描述

Sometimes, the best solution is to use both. Sometimes, it is to use neither. And sometimes, it is to use one or the other. If you want all the styles, including margin and padding reset across all browsers, use reset.css. Then apply all decorations and stylings yourself. If you simply like the built-in stylings but want more cross-browser synchronicity i.e. normalizations then use normalize.css. But if you choose to use both reset.css and normalize.css, link the reset.css stylesheet first and then the normalize.css stylesheet (immediately) afterwards. Sometimes it's not always a matter of which is better, but when to use which one versus when to use both versus when to use neither. IMHO.

css:每个浏览器都有一些默认的css样式,例如,在段落或标题周围添加填充。如果你添加了normalize样式表,所有这些浏览器默认规则将被重置,因此对于这个实例标签上的0px填充。这里有更多详细信息的链接:https://necolas.github.io/normalize.css/ http://nicolasgallagher.com/about-normalize-css/