!Important的使用及测试
来源:互联网 发布:js点击空白处触发事件 编辑:程序博客网 时间:2024/06/05 20:36
CSS的原理:
我们知道,CSS写在不同的地方有不同的优先级, .css文件中的定义 < 元素style>中的属性,但是如果使用!important,优先级会变得不一样。
使用!important的css定义是拥有最高的优先级的。但是在ie6下出了一点小的bug,注意书写方式一般可以轻松避开的。
<!DOCTYPE HTML>
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>测试!Important在ie6中区别</title>
</head>
<style type="text/css">
.testClass1{
color:blue !important;
}
.testClass2{
color:blue !important;
color: green;
}
.testClass3{
color: green;
color:blue !important;
}
.testClass4{
color:blue !important;
}
.testClass4{
color: green;
}
.testClass5{
color: green !important;
}
</style>
<body>
<div class="testClass1" style="color:red;">
测试Css1中的Important
</div>
<div class="testClass2" style="color:red;">
测试Css2中的Important
</div>
<div class="testClass3" style="color:red;">
测试Css3中的Important
</div>
<div class="testClass4" style="color:red;">
测试Css4中的Important
</div>
<div class="testClass5" style="color:red !important;">
测试Css5中的Important
</div>
</body>
</html>
虽然元素的style中有testClass类的定义,但是在上面的css定义中的用!important限定的定义却是优先级最高的,无论是在ie6-10或者Firefox和Chrome表现都是一致的,都显示蓝色。
在testClass1可以说明ie6是可以识别!important的。如果写成testClass2,ie6是识别不出来的,这是ie6的小缺陷。
不过这个问题可以通过testClass4的方式解决
0 0
- !Important的使用及测试
- !important的使用
- CSS中!important的使用 本篇文章使用最新的IE10以及firefox与chrome测试 !important优先级最高
- css 中!important的使用
- CSS中!important的使用
- CSS中!important的使用
- CSS中!important的使用
- CSS中!important的使用
- CSS中 !important 的使用
- CSS中!important的使用
- CSS中 !important 的使用
- CSS !Important及感叹号(!) hack的应用
- !important使用
- 如何和何时使用CSS的!important
- 如何和何时使用CSS的!important
- CSS——!important的使用场景
- css 权重及!important
- 使用jquery修改css中带有!important的样式属性
- notification的简单使用
- Item 22:数据成员应声明为私有 Effective C++笔记
- 初探Qt Opengl【1】
- IMX6Solo启动流程 外传-新建一条Uboot命令
- 三种排序方式
- !Important的使用及测试
- @media css样式
- 1094. The Largest Generation (25)
- Copy + Paste (Clipboard) Issues / Not Working?
- 无线路由器QoS设置——连接数限制
- IOS第三方代码收集
- 可以接收链路层MAC帧的原始套接字
- CCF 201412-4最优灌溉(MST)
- 获取Android手机CPU类型 ARM、ARMV7、NEON