84669 Lernen von Personen
152542 Lernen von Personen
20005 Lernen von Personen
5487 Lernen von Personen
7821 Lernen von Personen
359900 Lernen von Personen
3350 Lernen von Personen
180660 Lernen von Personen
48569 Lernen von Personen
18603 Lernen von Personen
40936 Lernen von Personen
1549 Lernen von Personen
1183 Lernen von Personen
32909 Lernen von Personen
内嵌式和!important谁优先级高?
定义及语法:
!important是CSS1就定义的语法,作用是提高指定样式规则的应用优先权。
语法格式:{ cssRule !important },即将!important写在定义的最后面,
例如:
box{color:red !important;}
<!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> 以下两个DIV的样式基本一样,但是第一个的外挂(理解俺的意思就行了)样式:background-color后面加了一个 !important,所以,虽然第一个DIV行内(in line)CSS也定义了background-color,但是却是参照外挂的background-color,其它的没有指定 !important 的,就被行内的STYLE覆盖掉了. <p class="aa" style="background-color:#cc6600;font-size:16px;">中Class中包括:!important的样式</p> <p class="bb" style="background-color:#cc6600">不包括的样式</p> </body> </html>
!important高,所以这个要尽量少用。
定义及语法:
!important是CSS1就定义的语法,作用是提高指定样式规则的应用优先权。
语法格式:{ cssRule !important },即将!important写在定义的最后面,
例如:
box{color:red !important;}
!important高,所以这个要尽量少用。