简体   繁体   English

一些CSS元素未显示

[英]Some CSS elements are not showing

Building a new website and using the 960 grid system, with the following css: 960_24_col text rest 使用以下CSS,构建一个新网站并使用960网格系统:960_24_col text rest

I'm also using my own style.css. 我也在使用自己的style.css。

So, I am trying to apply the following css to my header 2 (h2) 因此,我试图将以下CSS应用于标题2(h2)

h2 {
font-size: 26px;
text-transform: lowercase;
border-bottom: 1px solid yellow;
padding-bottom: 30px;
margin-bottom: 15px;
}

But it doesn't seem to apply. 但这似乎并不适用。 When I inspect the element in Chrome, some of the h2 elements are crossed out (line through it) in my style.css...when I copy the above code to say text.css..its works (but also applies to the other h1, h2, h3 etc) 当我检查Chrome中的元素时,某些h2元素在我的style.css中被划掉(穿过它)。当我复制上面的代码说text.css..its可以工作时(但也适用于其他h1,h2,h3等)

Any of you css wizards go any ideas? 你们中的CSS向导有什么想法吗?

CSS files are read in order. CSS文件按顺序读取。 So if one file is loaded which sets style on h1 , and another file is loaded that also sets style on h1 , the second one will overrule the first. 因此,如果加载了一个在h1上设置样式的文件,而另一个文件也在h1上设置样式的文件,则第二个文件将覆盖第一个文件。

A nasty way to fix that is to add !important to the end of your style, ie: 修正的一种讨厌方法是在样式的末尾添加!important ,即:

h2 {
    font-size: 26px;
    text-transform: lowercase;
    border-bottom: 1px solid yellow !important;
    padding-bottom: 30px;
    margin-bottom: 15px;
}

There must be some other style also defined for h2 in style.css the strike-through in chrome inspector means that this style has been over ridden, try finding any other occurrences for h2 in style.css 在style.css中还必须为h2定义其他样式。铬检查器中的删除线表示该样式已被覆盖,请尝试在style.css查找h2其他任何出现

Or if you want to keep both of style definitions due to some intentional changes you made try using !important after respective property which you don't want to be over-ridden to ask browser to give top priority to this style instead of others 或者,如果由于某些有意的更改而希望保留两种样式定义,则可以在各个属性之后尝试使用!important ,而您不想覆盖这些属性,以要求浏览器将此样式优先于其他样式

h2 {
font-size: 26px !important; /*same with every other property you want to give top priority*/
text-transform: lowercase;
border-bottom: 1px solid yellow;
padding-bottom: 30px;
margin-bottom: 15px;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM