【发布时间】:2011-03-15 15:30:45
【问题描述】:
我的网络应用中有两个 CSS 文件:reset.css 和 screen.css。它们以该顺序出现在 html 中(重置然后屏幕)。
在reset.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 {
border-bottom-width:0;
border-color:initial;
border-left-width:0;
border-right-width:0;
border-style:initial;
border-top-width:0;
font-family:inherit;
font-size:100%;
font-style:inherit;
font-weight:inherit;
margin-bottom:0;
margin-left:0;
margin-right:0;
margin-top:0;
outline-color:initial;
outline-style:initial;
outline-width:0;
padding-bottom:0;
padding-left:0;
padding-right:0;
padding-top:0;
vertical-align:baseline;
}
您可以看到span 在此列表中,默认情况下font-size 为 100%。
在我的 screen.css 中,我有以下内容:
dl.labels-left dt span.req {
display:inline;
font-size:14px !important;
}
我的 HTML 有以下摘录:
<div>
<dl class="labels-left">
<dt class="larger-a-left">
<label>Name:</label>
<span class="req">*</span>
</dt>
...
我遇到的问题是font-size: 14px !important; 被重置文件中的 CSS 覆盖,但仅在 Google Chrome 中。我不知道为什么!
这是一个 Firebug Lite 屏幕截图,显示 font-size 被划掉:
Firebug Screenshot http://www.damianbrady.com.au/images/firebug_screenshot.png
为什么我的 reset.css 样式被认为比特定的类定义更重要?
根据我对W3C CSS 2.1 Specificity的理解,这不应该发生!
【问题讨论】:
-
视觉上不是14px吗?也许检查员不正确地划掉它,但在视觉上它是正确的?
-
@meder - 你可能会在那里找到一些东西......你可以添加这个作为答案吗? :) 已确认 - 问题出在 Firebug Lite(和我的愿景)中。从视觉上看,它已经改变了。
标签: css google-chrome firebug css-selectors firebug-lite