关于 IE 这坨屎

世界上最不要脸的事情就是ie8也弹出提示:“是否要将IE设置为默认浏览器"!!!

记录下最近遇到的IE的bug,大部分是样式的问题,因为jquery很好的解决了js的兼容性问题。


1.ie6/7 当text-ident遇到inline-block时,整个标签会被缩进掉。解决方案:1使用block+float,但无法居中。2再标签前面加个 占位符即可。

2.ie下空标签失效解决办法:background:url(about:blank);

3. overflow失效!样式position:relative引起!解决:再父类加position:relative;

4.ie: margin双倍!浮动引起!解决:display:inline; 

5.透明:{filter: alpha(opacity=60)}


6.常用头部html代码

<!DOCTYPE html>
<!--[if lt IE 7 ]> <html lang="zh-CN" class="ie6"> <![endif]-->
<!--[if IE 7 ]>    <html lang="zh-CN" class="ie7"> <![endif]-->
<!--[if IE 8 ]>    <html lang="zh-CN" class="ie8"> <![endif]-->
<!--[if IE 9 ]>    <html lang="zh-CN" class="ie9"> <![endif]-->
<!--[if (gt IE 9)|!(IE)]><!--><html><!--<![endif]-->
<head>
<title></title>
<meta charset="utf-8" />

<meta name="renderer" content="webkit">                                                                                                         //360默认使用极速模式,即webkit内核
<meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0" />    //mobile下自适应,现在大多数智能手机的浏览器已经可以默认自适应了
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />                                                        //在未指定DOCTYPE时,在ie下文本模式会进入quirks模式,IE=edge会使其选择最高版本的文本模式,IE=8,则会选择文本模式IE8,如果安装了GCF,则可以使用chrome内核渲染(chrome太强大了),这里用处不大,因为一般都会有DOCTYPE,主要是在服务器上配置很有用。在服务器端指定响应头为IE=edge作用是:在使用以ie为内核的浏览器时(例如360安全模式)会使其文本模式选择最高版本的,这很重要。
apache下指定自定义http响应头

LoadModule headers_module modules/mod_headers.so

Header set X-UA-Compatible “IE=edge”

参考http://msdn.microsoft.com/library/cc817573.aspx



7.ie6下不支持console,ie7/8是支持的,但是使用360浏览器,当本地ie版本<=8时,当从极速模式切换到安全模式时,console对象会丢失,如果console.log则会导致页面挂掉。可以简单定义个:window.console = window.console || {log: Function};

8.页面变灰样式

html{  
    filter: grayscale(100%);   
    -webkit-filter: grayscale(100%);   
    -moz-filter: grayscale(100%);  
    -ms-filter: grayscale(100%);   
    -o-filter: grayscale(100%);
    filter: url("data:image/svg+xml;utf8,<svg xmlns="\'http://www.w3.org/2000/svg\'"><filter id="\'grayscale\'"><feColorMatrix type="\'matrix\'" values="\'0.3333" 0.3333="" 0="" 1="" 0\'=""></feColorMatrix></filter></svg>#grayscale"); 
    filter:progid:DXImageTransform.Microsoft.BasicImage(grayscale=1);  
    -webkit-filter: grayscale(1);
}

9.ie下的placeholder

define(['jquery'], function($){
    if('placeholder' in document.createElement('input')){
        return;
    }
    $("input[placeholder]").each(function(){
        var $this = $(this);
        if($this.attr("type") === "password"){
            return true;
        }
        var placeholder = $this.attr("placeholder");
        $this.focus(function(){
            if($this.val() == placeholder){
                $this.val("").focus();
            }
        });
        $this.blur(function(){
            if($this.val() == ""){
                $this.val(placeholder);
            }
        });
        if($this.val() == ""){
            $this.val(placeholder);
        }
    });
});



10.针对ie做处理的引用方式

<!--[if IE 6]><script src="/js/ie6.js" type="text/javascript" /></script><![endif]-->


11.ie6 绿色版下载地址http://download.csdn.net/download/a324539017/8363271


12.ie6 调试工具

 <script type="text/javascript" src=" https://getfirebug.com/firebug-lite-debug.js"></script> 
引入此js代码即可

13. ie8下背景图拉伸
filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src="xxx.png"), sizingMethod='scale');

14.ie8圆角
.ie8{
    .border-radius{
        behavior: url(/static/pie.htc);
        position: relative;
        z-index: 1;
    }
}
15.ie8下, input[type=text] 不给 line-height, 光标会在最上边,给 line-height 后,注意 不能使用 box-sizing: border-box;  safari 下光标会为行高


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值