<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<style type="text/css">
.aa{
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 12px;
background-color: #FF0000 !important
}
.bb{
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 12px;
background-color: #FF0000;
}
</style>
</head>
<body>
以下兩個(gè)DIV的樣式基本一樣,但是第一個(gè)的外掛(理解俺的意思就行了)樣式:background-color后面加了一個(gè) !important,所以,雖然第一個(gè)DIV行內(nèi)(in line)CSS也定義了background-color,但是卻是參照外掛的background-color,其它的沒(méi)有指定 !important 的,就被行內(nèi)的STYLE覆蓋掉了.
<div class="aa" style="background-color:#cc6600;font-size:16px;">中Class中包括:!important的樣式</div> <div class="bb" style="background-color:#cc6600">不包括的樣式</div>
</body>
</html>
大家可以在瀏覽器中運(yùn)行以上代碼查看效果
聯(lián)系客服