CSS样式重置
通常,为了使每个浏览器的样式都相同,您会看到一些网站有这样的内容:
html、正文、div、跨度、对象、... { 保证金:0; 填充:0; 边框:0; 字体大小:100%; 字体:继承; 垂直对齐:基线; 原因
不简单地使用:是否有
他们 *, html { ... }
Usually in order to get the style the same for every browser you see some sites have something like this:
html, body, div, span, object, ... {
margin: 0;
padding: 0;
border: 0;
font-size: 100%;
font: inherit;
vertical-align: baseline;
}
Is there a reason why they don't simply use:
*, html { ... }
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
CSS 规则集越广泛,加载它们所需的处理就越多。最好的规则集也是最具体的。
The more broad a set of CSS rules is, the more processing it'll take to load them. The best ruleset is also the most specific.
您可以使用类似的东西
来重置所有内容,最大的缺点是,它正是这样做的。然后段落没有任何间距等。我宁愿有通用的风格,也不愿没有风格并从头开始。
本文从标题为“重置到一切开始的地方......”的部分开始,也很好地解释了好处。
You can use something along the lines of
to reset everything, the big drawback is, it does exactly that. Then paragraphs don't have any spacing, etc. I'd rather have universal style than having no style and starting from scratch.
This article does a good job explaining the benefits as well, starting at the section titled "A reset to where it all started…"