原來CSS裡的 !important 是如此用法_經驗交流

來源:互聯網
上載者:User
點擊查看效果:

<!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覆蓋掉了. 中Class中包括:!important的樣式 不包括的樣式 </body> </html>
[Ctrl+A 全選 注:如需引入外部Js需重新整理才能執行]
  • 相關文章

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.