Webkit CSS 重置?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5290777/
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-29 23:55:03  来源:igfitidea点击:

Webkit CSS Reset?

csswebkit

提问by Joseph Duffy

I know there's a few CSS Reset tools out there, Eric's and Yahoo's to name 2.
However, when I'm using certain tags (I think they're called tags?) such as "li" and "ul", I get some extras in the User Agent Stylesheet. Some of these are:

我知道有一些 CSS 重置工具,Eric 和 Yahoo 的名字是 2。
但是,当我使用某些标签(我认为它们被称为标签?)例如“li”和“ul”时,我得到了一些用户代理样式表中的附加功能。其中一些是:

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

I'm wondering if there's a reset stylesheet out there that deals -webkit etc?
I have searched for one, but with now luck.

我想知道是否有处理 -webkit 等的重置样式表?
我已经搜索了一个,但现在很幸运。

采纳答案by Andrew Moore

While these styles are applied by Webkit, they are over-ruled by margin: 0; padding: 0;located in the CSS resets. You don't have to worry about them.

虽然这些样式是由 Webkit 应用的,但它们margin: 0; padding: 0;在 CSS 重置中被定位。你不必担心他们。

Note: Although Chrome (Version 27.0.1453.116 m) Developer Tools does not display the user agent styles with strikethrough, the computed styles do reflect that explicit marginand paddingvalues override.

注意:虽然 Chrome(版本 27.0.1453.116 m)开发者工具没有显示带删除线的用户代理样式,但计算的样式确实反映了显式marginpadding值覆盖。

回答by PavlosVos

Acctually if you are working with <ul>in your markup the reset margin: 0, padding: 0;do not overwrite the -webkit-padding-start: 40px;

实际上,如果您 <ul>在标记中使用重置margin: 0, padding: 0;不会覆盖-webkit-padding-start: 40px;

I solved the problem by adding to my reset file a

我通过添加到我的重置文件解决了这个问题

ul {
    -webkit-padding-start: 0px;
}

回答by bastien

I had the same problem with liand ul, and found the following solution: in my CSS, I had an attribute for the liof my list which was display: inline. I replaced it with float: leftand it works. I don't know why...

我在liand 上遇到了同样的问题ul,并找到了以下解决方案:在我的 CSS 中,li我的列表中有一个属性是display: inline. 我用它替换了它float: left并且它有效。我不知道为什么...

回答by tony gil

If user agent stylesheetis being called, it is because the property that is called for / needed was not properly defined in your css stylesheet.

如果user agent stylesheet正在调用,那是因为在您的 css 样式表中未正确定义为 /需要调用的属性。

Error check your CSS using a tool like CSS Lintand fix any problems that might be detected before trying workarounds.

使用CSS Lint 之类的工具错误检查您的 CSS,并在尝试变通方法之前修复可能检测到的任何问题。

回答by story

I was having this same problem with my <h3>tag. I tried setting margin:0;, but it didn't work.

我的<h3>标签也有同样的问题。我试过设置margin:0;,但没有用。

I found that I was habitually commenting out lines in my css by using //. I never noticed it because it hadn't caused any problems before. But when I used //in the line before declaring <h3>, it caused the browser to skip the declaration completely. When I traded out //for /**/I was able to adjust the margin.

我发现我习惯性地使用//. 我从来没有注意到它,因为它以前没有引起任何问题。但是当我//在声明之前的行中使用时<h3>,它导致浏览器完全跳过声明。当我//换出时,/**/我能够调整保证金。

Moral of this story: Always use proper commenting syntax!

这个故事的寓意:始终使用正确的注释语法!