Reset.css 会影响其他样式表吗?
我正在开始一个新项目,所以我想开始在我的项目中使用 Reset.css 。我得到了使用 Reset.css 的概念,但困扰我的一件事是,如果影响我在同一元素上应用的其他样式..就像在 Reset.css div 中具有 0 边距和 0 填充...并且如果我应用我的样式表中的某些 div 的边距,不会受到干扰吗?
请澄清我的这个疑问
I am starting a new project, so i thought to start using Reset.css in my projects. i got the concept of using Reset.css, but one thing is bothering me is that does if affects my other style applied on the same element.. like in reset.css div have 0 margin and 0 padding... and if i apply margin to some of the divs in my stylesheet, wont it get disturbed?
Please clear my this doubt
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果应用于其他 div 的样式更加具体,则不会。
http://coding.smashingmagazine.com/ 2007/07/27/css-specificity-things-you-should-know/
一般来说,使用类或选择器中的 id 应用的任何样式都将优先于一个没有。但您应该了解该领域的许多其他规则。
即
永远会否决
Not if the style applied to your other divs is more SPECIFIC.
http://coding.smashingmagazine.com/2007/07/27/css-specificity-things-you-should-know/
In general any style applied using a class, or an id in the selector is going to take precedence over one which doesn't. But there are many other rules in this area you should become aware of.
i.e.
will always overrule
您必须首先包含reset.css,然后包含您自己的样式表文件。并确保您的样式不会被reset.php覆盖。
You have to include reset.css first and then include your own stylesheet file. and be sure that your styles wont be overwritten by reset.php.
您需要做的是加载reset.css作为第一个样式表。
之后加载的任何其他内容都将覆盖reset.css,
例如,如果您在reset css中指定:p { margin:0px;内边距:0px}
然后使用 style: p {margin: 2px; 加载 style.css padding: 2px}
将使用最后一个样式加载。
我个人使用技术
将其放在 css 文件的顶部并完成工作:) 不需要额外的 .css 文件。
What you neeed to do is load reset.css as a first style sheet.
Anything else loaded after it will be overriding reset.css
e.g if you specify in reset css: p { margin: 0px; padding: 0px}
and than load style.css with style: p {margin: 2px; padding: 2px}
The style load as last one will be used.
I personaly use technic with
Put it at the top of css file and job done:) No need for extra .css fil.