为什么不使用星号重置 CSS?
可能的重复:
(为什么)CSS 星形选择器被认为是有害的? < /p>
我注意到许多 CSS 开发人员通过在开头显式声明所有 HTML 元素来重置大量 HTML 元素的边距、字体和填充(例如 Yahoo 和 meyerweb 版本)。所以我问自己,为什么不使用 * 进行简单的全局重置?我知道这会破坏某些元素(如按钮和块引用)的布局,但这些元素可以轻松地重新设计样式,如果您确实想重置布局,这是必须的,因为按钮在所有浏览器中具有不同的外观。
Possible Duplicate:
(why) is the CSS star selector considered harmful?
I noticed that many CSS developers reset the margin, font and padding of a big number of HTML elements by explicitly declaring them all in the beginning (e.g.Yahoo and meyerweb versions). So I ask myself, why not simple reset globally using the *? I know that this break the layout for some elements like buttons and blockquotes but those can easily be restyled, which is a must if you really want to reset the layout because buttons have different looks in all browsers.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我想您刚刚回答了自己 - 这不是简单的重新设计按钮和表单控件,因为所有用户代理都有非常具体的样式来迎合他们。
I think you just answered yourself - it's not simple restyling buttons and form controls because all user agents have very specific styling catering toward them.
我认为针对特定控制的想法是为了提高性能。显然“*”选择器非常昂贵。否则,我不相信使用类似下面的东西除了性能之外不会产生太大影响(我认为这是有争议的)
I think the idea of targeting specific controls was to improve performance. Apparently the "*" selector is very expensive. Otherwise, I don't believe using something like the below would have much impact other than performance ( Which is debatable I suppose )