怎么强制使用css表style覆盖html的style

html-css08

怎么强制使用css表style覆盖html的style,第1张

你只能试试 !important 了. 因为内联样式优先级高于外部引用样式. 而脚本修改样式的语句又高于以上两种.所以,如果脚本里用到了object.style.xxxx='xxx'的话,那你只能再用脚本修改,如果脚本是用document.write输出的话, !important 应该可以优先于内联样式.

.jqplot-table-legend {

xxxx: xxxx!important

}

先这样试试看,如果不行就用脚本.

如果脚本里用到了object.style.xxxx='xxx'的话,那你只能再用脚本修改,如果脚本是用document.write输出的话,,important 应该可以优先于内联样式。

jqplot-table-legend {

xxxx: xxxx!important

}

先这样试试看,如果不行就用脚本。

再谈一下css中style属性怎么使用:

一种是写在style标签中,一种是使用link引用外部标签

<head>

<link href="外部CSS文件地址" rel="stylesheet">

</head>

或者

<style>

body{

background:blue

}

</style>

1、!important 表示强制应用该样式,例如:button{ width: 150px !important},与以上的选择器相遇时,强制使用此样式;

2、如果比较后权重相同,那么后者覆盖前者,后渲染的胜出;

3、内联样式 >id选择器样式 >类选择器样式 >元素选择器样式;

4、CSS选择器的使用,应该尽量避免使用 !important 和 内联样式;id通常也是与class区分开使用,前者多用于JS中的结点定位,后者多用于CSS选择器。