[英]CSS stylesheets being override even it is in last sequence
Here is some code of my main jsp file: 这是我的主要jsp文件的一些代码:
<link rel="stylesheet" type="text/css" href="<c:url value='/styles/bootstrap.min'/>,bootstrap-switch.min.css" />
<link rel="stylesheet" type="text/css" media="screen" href="<c:url value='/styles/main.css'/>"/>
The main.css
is at the line after bootstrap css
, so usually, main.css
will override the bootstrap css
. main.css
在bootstrap css
之后的行中,因此通常, main.css
将覆盖bootstrap css
。 (correct me if I am wrong.) (如果我做错了,请纠正我。)
Inside main.css
, I have create 1 class as follow: 在
main.css
内部,我创建了1个类,如下所示:
.testjx{
background-color: yellow;
vertical-align:middle;
}
And here is my sub jsp file: 这是我的子jsp文件:
<td class="testjx">
1000000
</td>
When I view the page in browser, I found that vertical-align:middle
is override by bootstrap css
file, as follow screen shot: 当我在浏览器中查看页面时,我发现
bootstrap css
文件覆盖了vertical-align:middle
,如以下屏幕截图所示:
I try my best to find out the root cause, but fail. 我尽力找出根本原因,但是失败了。 Kindly advise.
好心提醒。
You must do like this: 您必须这样做:
table tr td.testjx, table tfoot tr td.testjx, table thead tr td.testjx, table tbody tr td.testjx{
vertical-align:middle;
}
You need to inspect where the class is to short the css code...check if is on the tfoot, thead or tbody or general
您需要检查该类在哪里缩短CSS代码...检查是在脚踩脚,thead还是tbody或将军上
I get around this by adding !important
to the relevant CSS ie font-weight:bold !important;
我通过在相关CSS中添加
!important
来解决此问题,即font-weight:bold !important;
and this stops it being overridden regardless of which file it's in. Simples. 并且这将阻止它被覆盖,无论它在哪个文件中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.