CSS 摆脱用户代理样式表规则?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6528144/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-30 00:53:48  来源:igfitidea点击:

Getting rid of user-agent stylesheet rules?

cssgoogle-chromewebkitreset

提问by Andrei Zisu

Something odd is happening in my Chome 12.

我的 Chome 12 中发生了一些奇怪的事情。

I downloaded the latest boilerplate a few days ago and designed on it. Everything was ok.

几天前我下载了最新的样板并在其上进行了设计。一切正常。

5 minutes ago, Chrome (Webkit) all of a sudden decided to insert extra css rules in my design:

5分钟前,Chrome(Webkit)突然决定在我的设计中插入额外的css规则:

-webkit-margin-before: 1em;
-webkit-margin-after: 1em;
-webkit-margin-start: 0px;
-webkit-margin-end: 0px;
-webkit-padding-start: 40px;

How do I get rid of this, without adding extra resets?

如何在不添加额外重置的情况下摆脱这种情况?

Edit: also met the problem with h1 elements

编辑:也遇到了 h1 元素的问题

-webkit-margin-before: 0.67em;
-webkit-margin-after: 0.67em;
-webkit-margin-start: 0px;
-webkit-margin-end: 0px;

Edit2: my reset contains

Edit2:我的重置包含

html, body, div, span, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre,
abbr, address, cite, code, del, dfn, em, img, ins, kbd, q, samp, small, strong, sub, sup,
 var, b, i, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, 
tfoot, thead, tr, th, td, article, aside, canvas, details, figcaption, figure, footer, 
header, hgroup, menu, nav, section, summary, time, mark, audio, video
 { margin: 0; padding: 0; border: 0; font-size: 100%; font: inherit; vertical-align: baseline; }

采纳答案by Andrei Zisu

Pff, there were misformated comments in my css files, which disabled the reset...

噗,我的 css 文件中有格式错误的注释,导致无法重置...

回答by thirtydot

Those properties are overridden by marginand padding.

这些属性被margin和覆盖padding

Just set margin: 0; padding: 0if you want the marginand paddinggone.

只需设置margin: 0; padding: 0,如果你想marginpadding走了。

Those properties didn't just suddenly appear, they've been there since forever.

那些属性不是突然出现的,它们一直存在。

Proof by demonstration: http://jsfiddle.net/VNh3u/- (obviously, check in a WebKit browser)

演示证明:http: //jsfiddle.net/VNh3u/- (显然,检查 WebKit 浏览器)