我的网络应用程序中有两个 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中。我不知道为什么!
font-size
这是显示划掉
的 Firebug Lite 屏幕截图: Firebug 屏幕截图 http://www.damianbrady.com.au/images/firebug_screenshot.png
为什么我的 reset.css 样式被认为比特定的类定义更重要?
根据我对W3C CSS 2.1 Specificity的理解,这不应该发生!