標籤:
1.!important能將當前的CSS代碼優先權提升為最高
1.1
<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><title>Document</title><style>div{ width:100px; height:100px; background-color:blue !important;}</style></head><body> <div style="background-color:red"> </div></body></html>
1.2
<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><title>Document</title><style>div{ width:100px; height:100px; background-color:blue !important; background-color:red;}</style></head><body> <div > </div></body></html>
但是在IE <=6中這樣設定是無效的,需要這樣
<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><title>Document</title><style>div{ width:100px; height:100px; background-color:blue !important; }div{ background-color:red;}</style></head><body> <div > </div></body></html>
[email protected]的作用類似於link標籤,都是將外部CSS代碼匯入
2.1在style標籤中使用
<style>@import "1.css"</style>
2.2在css檔案中使用
div{ width:100px; height:100px;}@import "2.css";
CSS之!important和@import