问题描述
我的网络应用程序有两个CSS文件:reset.css和screen.css。
I have two CSS files in my web app: reset.css and screen.css. They appear in that order in the html (reset then screen).
在reset.css中,会出现以下样式定义:
In the reset.css, the following style definition occurs:
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
在此列表中,默认情况下具有100%的 font-size
。
You can see that span
is in this list, and by default has a font-size
of 100%.
.css,我有以下:
In my screen.css, I have the following:
dl.labels-left dt span.req {
display:inline;
font-size:14px !important;
}
我的HTML有以下摘录:
My HTML has the following excerpt:
<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中。我不能解决为什么!
The problem I'm having is that the font-size: 14px !important;
is being overridden by the CSS in the reset file, but only in Google Chrome. I can't work out why!
这是一个Firebug Lite屏幕截图,显示 font-size
b $ b
Here's a Firebug Lite screenshot showing the font-size
crossed out:
为什么我的reset.css样式被认为比特定的类定义更重要?
根据我对,这不应该发生!
According to my understanding of W3C CSS 2.1 Specificity, this shouldn't happen!
推荐答案
也许检查员不正确地越过它,但视觉上是正确的?
Maybe the inspector is crossing it out improperly but visually it's right?
这篇关于为什么我的!important属性不能在Google Chrome中使用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!