css hack分类及使用方法

来源:互联网 发布:linux文件分别打包命令 编辑:程序博客网 时间:2024/06/05 08:34

css hack有三种分别为:
1.IE条件注释法

 <!--[if IE]> //表示只在IE下生效  <link type="text/CSS" href="test.css" rel="stylesheet"/>  <! [endif]--> <!--[if IE 6]> //表示只在IE6下生效  <link type="text/CSS" href="test.css" rel="stylesheet"/>  <! [endif]--> <!--[if gt IE 6]> //表示只在IE6以上版本下生效  <link type="text/CSS" href="test.css" rel="stylesheet"/>  <! [endif]--> <!--[if ! IE 7]> //表示只在IE7下不生效  <link type="text/CSS" href="test.css" rel="stylesheet"/>  <! [endif]--> <!--[if IE 6]> //条件注释style标签  <style type="test/CSS">    .test{}   </style> <! [endif]--> <!--[if IE 6]> //条件注释script标签  <script type="text/JavaScript">   alert("1111")  </script> <! [endif]--> lte小于等于,lt小于,gte大于等于,gt大于,!不等于

2.选择符前缀法

<style type="test/CSS">  .test{width:100px;}  *html .test{width:150px;}  //只适用于IE6  *+html .test{width:50px;}  //只是用于IE7</style>*表示只是只对IE6生效,*+表示只对IE7生效

3.样式属性前缀法

<style type="test/CSS">  .test{width:90px;*width:70px;_width:35px;} </style>_只在IE6下生效,*在IE67下生效
原创粉丝点击