zoukankan      html  css  js  c++  java
  • IE浏览器各版本的CSS条件判断 (转)

    IE版本不动,有些地方的css表现也不同。为了hack,有时候需要用到版本判断。

    经典的hack是使用型号*下横线_感叹号!加属性来做的(详见文章CSShack,区分IE6,IE7,Firefox),不过感觉比较麻烦。还有一种是直接用条件语句来写的,见下文:

    IE8出到现在还没敢装,前些天下载了个Xenocode Browser Sandbox安装了下,发现之前一直用的一个纯CSS横向导航的水平居中出了问题,在IE8下完全居左了。找了很久没发现问题所在,索性每份CSS分开 屏蔽,最终确定是针对IE的CSS问题,得避掉IE8只对IE7及以下版本设置。

    之前只是针对所有的IE浏览器:

    <!--[if IE]> <link href="Style/IE.css" rel="stylesheet" type="text/css" /> <![endif]-->

    要避掉IE8的话就得:

    <!--[if lt IE 8]> <link href="Style/IE.css" rel="stylesheet" type="text/css" /> <![endif]-->

    lt在此作小于用,也就是小于IE8的版本都能识别。

    或者:

    <!--[if lte IE 7]> <link href="Style/IE.css" rel="stylesheet" type="text/css" /> <![endif]-->

    lte在此作小于及等于用,也就是小于及等于IE7的版本能识别。

    或者:

    <!--[if !(IE 8)]> <link href="Style/IE.css" rel="stylesheet" type="text/css" /> <![endif]-->

    <!–[if !(IE 8)]><![endif]–>在此单独避掉IE8版本。

    在网上找了以下代码,测试了下有几个不符合:

    1. <!--[if !IE]><!--> 除IE外都可识别 <!--<![endif]-->

    2. <!--[if IE]> 所有的IE可识别 <![endif]-->

    3. <!--[if IE 5.0]> 只有IE5.0可以识别 <![endif]-->

    4. <!--[if IE 5]> 仅IE5.0与IE5.5可以识别 <![endif]-->

    5. <!--[if gt IE 5.0]> IE5.0以及IE5.0以上版本都可以识别 <![endif]-->

    6. <!--[if IE 6]> 仅IE6可识别 <![endif]-->

    7. <!--[if lt IE 6]> IE6以及IE6以下版本可识别 <![endif]-->

    8. <!--[if gte IE 6]> IE6以及IE6以上版本可识别 <![endif]-->

    9. <!--[if IE 7]> 仅IE7可识别 <![endif]-->

    10. <!--[if lt IE 7]> IE7以及IE7以下版本可识别 <![endif]-->

    11. <!--[if gte IE 7]> IE7以及IE7以上版本可识别 <![endif]-->

    经过测试后:

    5. <!--[if gt IE 5.0]> IE5.0以及IE5.0以上版本都可以识别 <![endif]-->

    这个只有IE6以上的版本才可识别,也就是不包括IE5.0

    7. <!--[if lt IE 6]> IE6以及IE6以下版本可识别 <![endif]-->

    这个只有IE5以下的版本才能识别,也就是不包括IE6

    10. <!--[if lt IE 7]> IE7以及IE7以下版本可识别 <![endif]-->

    这个只有IE6以下的版本才能识别,也就是不包括IE7

    后来才在经典那找到:

    gt = Great Than 大于 > = > 大于号

    lt = Less Than 小于 < = < 小于号

    gte = Great Than or Equal 大于或等于

    lte = Less Than or Equal 小于或等于

    一下就明白过来了,还费了那么大劲。

  • 相关阅读:
    阿里云Centos7安装和启动nginx
    mysql安装配置、主从复制配置详解
    php 文件大小计算转换
    tp5.0 生成二维码 + 合并海报图
    iTerm2 + Oh My Zsh
    linux 安装 卸载 命令
    php两个时间日期相隔的天数,时,分,秒.
    PhpStorm下载 + 破解
    php 地区三级联动
    PhpSpreadsheet 引入类库 导出 excel
  • 原文地址:https://www.cnblogs.com/hejia/p/2701505.html
Copyright © 2011-2022 走看看