上边距显示为 18px 但未在 css 中设置

Top margin displaying as 18px but not set in css

我在确定我们项目使用的各种 css 文件中 p 元素的边距设置位置时遇到了一些问题。边距规则不会出现在 IE 或 Chrome 的开发人员工具 (F12) 的元素检查器的 css 列表中(尽管 Chrome 当然在底部包含图表css 规则列表告诉我从某处应用了 18px 的顶部和底部边距)。

我刚刚使用 'Grep' 在项目中的所有文件中搜索字符串:"margin: 18px"、"margin-top: 18px"、"margin:18px" 和 "margin-top:18px"。没有比赛。

我的问题是 - 还有什么其他方法可以设置边距?可以将其设置为其他属性的副产品吗?我知道这是一个愚蠢的建议,但我不确定还能想些什么。

而且我检查并重新检查了元素检查器中的 css 列表,但未显示边距规则 - 尽管 Chrome 告诉我,仅在该图表中,边距是以某种方式设置。

任何新知识,非常感谢,谢谢。

编辑
明确一点 - 当我谈到检查 'css list of the element inspector in the developer tools' 时,我的意思是我已经检查了 IE 和 Chrome.
中 F12 开发人员工具中的元素 很抱歉回避,但该项目太大而无法在 js 中演示 fiddle。

CSS 2.1 specification has an default style sheet for HTML 4. 它只是提供信息而不是规范,因此浏览器可能会使用它,但不必使用它。

另一个资源可能是浏览器的网络开发工具。大多数可以向您显示应用于特定元素的级联规则。例如:Firefox 和 Safari (WebKit) 似乎对 p 元素使用 margin: 1em 0px

浏览器总是内置 "safe zone"。您可以使用简单的 "rule sheet".

通过 CSS 覆盖它
html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, font, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td {
    margin: 0;
    padding: 0;
    border: 0;
    outline: 0;
    font-weight: inherit;
    font-style: inherit;
    font-size: 100%;
    font-family: inherit;
    vertical-align: baseline;
}
:focus {
    outline: 0;
}
body {
    line-height: 1;
    color: black;
    background: white;
}
ol, ul {
    list-style: none;

我希望这个 "reset" 能帮到您!

浏览器有一些内置的 CSS 规则,您需要覆盖这些规则以确保您基本上有一个 'blank canvas' 可以构建。一个很好且广泛使用的重置 CSS 是 Eric Meyer's CSS Reset - 将重置 CSS 的内容复制到一个新的 reset.css 文件中,并在包含项目的自定义 [=15] 之前包含它=].