Home > Web Front-end > HTML Tutorial > css的!important用法介绍_html/css_WEB-ITnose

css的!important用法介绍_html/css_WEB-ITnose

WBOY
Release: 2016-06-24 11:28:53
Original
1593 people have browsed it

css的!important用法介绍:
!important可以提升css语句的权重,下面就通过代码实例做一下简单介绍。
它有些浏览器兼容性问题,出在奇葩的IE6浏览器身上,不过问题不大,因为IE6的用户以后会越来越少直到绝迹。
代码如下:

<!DOCTYPE html><html><head><meta charset=" utf-8"><meta name="author" content="http://www.softwhy.com/" /><title>蚂蚁部落</title><style type="text/css">#antzone{  width:150px;  height:100px;  background-color:green!important;}#antzone{  background-color:blue;}</style> </head> <body> <div id="antzone"></div></body> </html>
Copy after login

上面的代码中,如果不使用!important话,那么背景颜色就是蓝色,因为后面的语句会覆盖前面的,但是如果使用!important就会提升响应语句的权重了,关于IE6的兼容性问题,可以参阅CSS的!important语法规则一章节。

原文地址是:http://www.softwhy.com/forum.php?mod=viewthread&tid=15084

更多内容可以参阅:http://www.softwhy.com/divcss/

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template