标签:
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>
2.@import的作用类似于link标签,都是将外部CSS代码导入
2.1在style标签中使用
<style> @import "1.css" </style>
2.2在css文件中使用
div{
width:100px;
height:100px;
}
@import "2.css";
标签:
原文地址:http://www.cnblogs.com/bibiafa/p/5867908.html