如何使用外部CSS覆盖内联样式?我有使用内联样式的标记,但是我没有权限更改这个标记。如何仅使用CSS覆盖文档中的内联样式?我不想使用jQuery或JavaScript。HTML:<div style="font-size: 18px; color: red;">
Hello World, How Can I Change The Color To Blue?</div>CSS:div {
color: blue;
/* This Isn't Working */}
3 回答
慕侠2389804
TA贡献1719条经验 获得超6个赞
inline-styles
div
blue
inline style
color
red
<div style="font-size: 18px; color: red;"> Hello World, How Can I Change The Color To Blue?</div>
div { color: blue; /* This Won't Work, As Inline Styles Have Color Red And As Inline Styles Have Highest Priority, We Cannot Over Ride The Color Using An Element Selector */}
element-attr
!important
!important
<div style="font-size: 30px; color: red;"> This is a test to see whether the inline styles can be over ridden with CSS?</div>
div[style] { font-size: 12px !important; color: blue !important;}
注:使用 !important
只会在这里工作,但我用过 div[style]
选择器专门选择 div
有 style
属性
凤凰求蛊
TA贡献1825条经验 获得超4个赞
!important
<div style="font-size: 18px; color: red;"> Hello World, How Can I Change The Color To Blue?</div>div { color: blue !important; /* This will Work */ }
<div style="font-size: 18px; color: red !important;"> Hello World, How Can I Change The Color To Blue?</div>div { color: blue !important; /* This Isn't Working */ }
red
- 3 回答
- 0 关注
- 1892 浏览
相关问题推荐
添加回答
举报
0/150
提交
取消