一、认识css hack

CSS Hack只要是来解决浏览器局部的兼容性问题,主要是因为每个浏览器对css的解析各不相同,导致输出到页面的效果的差异;

二、css hack的三种常见形式:css属性hack,css选择符hack和css针对IE浏览器的条件注释hack

1、css属性hack:比如IE6能识别"_"和"*",IE7能识别"*"但不能识别"_";

2、选择符级Hack:IE6能识别*html .class{} IE7能识别*+html .class{}或者*:html .class{};

3、针对ie的条件注释Hack:比如针对所有IE:<!–[if IE]><!–您的代码–><![endif]–>针对IE6及以下版本:<!–[if lt IE 7]><!–您的代码–><![endif]–>,此时写在判断力的代码都生效。

三、hack例子

1、CSS属性级Hack

color:red; /*所有浏览器*/    _color:red; /*仅IE6*/    *color:red; /*IE6和IE7*/  +color:red; /*仅IE6*/   color:red; /* IE8、IE9 识别*/ color:red9; /* 仅IE9识别 */    color:red!important; /* IE6 不识别!important*/

2、CSS选择符级Hack

*html #container { color:red;} /* 仅IE6 识别 */    *+html #container { color:red;} /* 仅IE7 识别 */

3、IE条件注释Hack

<!--[if IE]>此处内容只有IE可见<![endif]-->    <!--[if IE 6]>此处内容只有IE6.0可见<![endif]-->    <!--[if IE 7]>此处内容只有IE7.0可见<![endif]-->   <!--[if gt IE 6]> IE6以上版本可识别,IE6无法识别 <![endif]-->    <!--[if gte IE 7]> IE7以及IE7以上版本可识别 <![endif]--> <!--[if lt IE 7]> 低于IE7的版本才能识别,IE7无法识别。 <![endif]-->    <!--[if lte IE 7]> IE7以及IE7以下版本可识别<![endif]-->   <!--[if !IE]>此处内容只有非IE可见<![endif]-->

最新文章

  1. FacadePattern(门面模式)
  2. Selenium IDE 基础教程
  3. react-native疑难
  4. aps.net 图形验证码(转)
  5. 网络通信分享(二):外网ip和内网ip
  6. phpwind8.7升级9.0.1过程(二)8.7正式升级9.0
  7. ubuntu -LDAP的配置
  8. JavaScript学习笔记之下拉选择框的操作
  9. jQuery滑过头像图片展示个人信息效果
  10. SystemTrayDemo
  11. Java基础---集合
  12. 0_Simple__simpleAtomicIntrinsics + 0_Simple__simpleAtomicIntrinsics_nvrtc
  13. 通过返回动态改变textview和imageview
  14. ASP.NET MVC利用PagedList分页(一)
  15. Neo4j导入本地csv问题
  16. January 04th, 2018 Week 01st Thursday
  17. 【PMP】变更流程图与说明
  18. 【Tools】-NO.4.Tools.1.VM.1.001-【VMware Workstation PRO 12 Install CentOS 7.1】-
  19. 【ASP.Net】 web api中的media type
  20. &lt;mvc:annotation-driven /&gt; 作用

热门文章

  1. 指针常量&amp;常量指针&amp;指向常量的指针常量
  2. Azure 静态 web 应用集成 Azure 函数 API
  3. Linux mysql 修改密码 三种方式(转载)
  4. grep/字符/次数匹配/锚定符/小大括号/wc/tr/cut/sort/uniq
  5. Django 配置 Mysql
  6. vue-子组件为接受到父组件的数据
  7. 死磕以太坊源码分析之p2p节点发现
  8. HBase高级特性、rowkey设计以及热点问题处理
  9. 3种办法教你解决Vegas预览画面卡顿问题
  10. guitar pro 系列教程(六):Guitar Pro音频导出功能之RSE音源