zoukankan      html  css  js  c++  java
  • 常见浏览器的兼容问题

      初学html和css时,每天切图,总会遇到很多浏览器兼容性问题。最近一直关注移动平台开发,就html和css来说,不用考虑那么多浏览器兼容性问题。到现在,以至于很多浏览器兼容性几乎忘光了。今天把以前总结的知识拿来分享一下,顺便自己也复习一下。当然,其中肯定有很多不足,望指正啊。
     

    1 ie6.0横向margin加倍

    产生因素:块属性、float、有横向margin。
    解决方法:display:inline;

    2 ie6.0下默认有行高

    解决方法:overflow:hidden;或font-size:0;或line-height:xx px;

    3 在各个浏览器下img有空隙(原因是:回车。)

    解决方法:让图片浮动。

    4 一个父标签与几个子标签嵌套,父标签不浮动,子标签float,子标签不撑开父的高度。

    解决方法:a 在子标签最后清浮动{<div style="height:0;clear:both;">&nbsp;</div>}
                      b 父标签添加{overflow:hidden;}
                      c 给父标签设置高度

    5 Ie6下,不识别最大宽、高度和最小宽高度,意即min-width/height和 Max-width/height在ie6中没效果,

    解决方法:(1):.abc{border:1px blue solid;200px;height:200px;}
                              html>body .abc{auto;height:auto;min-200px;min-height:200px;}
            (2):.abc{200px;height:200px;_200px;_height:200px;}(因为ie6有一个特征,当定义一个高度时,如果内容超过高度,元素会自动调整高度。)

    6 Ie6里面:如li设宽、高,并且li里面的标签浮动,那么li之间会有间距

    解决方法:li不设宽、高或者li内的标签不浮动

    7  li之间有间距

    解决方法:li 设置vertical-align:middle;

    8 3像素问题:ie6下,当浮动元素与流动元素并列显示时,他们之间会存在三像素问题。

       解决方法:用hack技术, 例如:所有浏览器通用 height:100px; 
                                                      ie6专用_height:100px;
                                                      ie7专用*+height:100px; 
                                                      ie6/ie7共用*height:100px;

    9 当定义行内元素为包含框时,且包含框包含的绝对定位元素以百分比为单位进行定位时,会出现混乱。

        解决方法:在行内元素里加入{zoom:1;}

    10 当多个浮动元素中间夹杂着HTML注释语句时,如果浮动元素宽度为100%,则在下一行多显示一个上一行最后一个字符。

            解决办法:给浮动元素添加display:inline;。

    11 opacity 定义元素的不透明度

      filter:alpha(opacity=80);/*ie支持该属性*/
      opacity:0.8;/*支持css3的浏览器*/

    12 两个块元素,竖向的margin值不增加,会重叠,其间距为最大margin值。

    13 优先级:被!important 注明的css属性具有最高优先级(.abc{color:red !important;})。但在ie6中!important具有一个bug:在同一组css属性中,!important不起作用。

    14 火狐不识别background-position-y 或background-position-x;

     

    ---------------------------2014.01.10补充-------------------------------

    15 ie6 不支持 fixed 

    复制代码
    /*对于非IE6可以这样写*/
    #top{  
        position:fixed;  
        bottom:0;  
        right:20px;  
    }  
    
    /*但是IE6是不支持fixed定位的,需要另外重写*/
    #top{  
        position:fixed;  
        _position:absolute;  
        top:0;  
        right:20px;  
        _bottom:auto;  
        _top:expression(eval(document.documentElement.scrollTop));
    }  
    
    /*使用hack使IE6实现该效果,但这个东东会闪烁,需要以下代码*/
    *html{  
        background-image:url(about:blank);  
        background-attachment:fixed;  
    }  
    
    /*使固定在顶部*/
    #top{  
        _position:absolute;  
        _bottom:auto;  
        _top:expression(eval(document.documentElement.scrollTop));  
    }  
    
    /*固定在底部*/
    #top{  
        _position:absolute;  
        _bottom:auto;  
        _top:expression(eval(document.documentElement.scrollTop+document.documentElement.clientHeight-this.offsetHeight-(parseInt(this.currentStyle.marginTop)||0)-(parseInt(this.currentStyle.marginBottom)||0)));  
    }  
    /*垂直居中*/
    #top{
        position:fixed;
        top:50%;
        margin-top:-50px;
        _position:absolute;
        _top:expression(eval(document.documentElement.scrollTop+document.documentElement.clientHeight/2)); 
    }
    复制代码

    16  解决 ie6 最大、最小宽高 hack方法

    复制代码
    /* 最小宽度 */
    .min_width{
        min-300px;
        _expression(parseInt(this.clientWidth) < 300 ? "300px" : this.clientWidth);
    }
    
    /* 最大宽度 */
    .max_width{
       max-600px;
       _expression(parseInt(this.clientWidth) > 600 ? "600px" : this.clientWidth);
    }
    
    /* 最小高度 */
    .min_height{
       min-height:200px;
       _height:expression(parseInt(this.clientHeight) < 200 ? "200px" : this.clientHeight);
    }
    
    /* 最大高度 */
    .max_height{
       max-height:400px;
       _height:expression(parseInt(this.clientHeight) > 400 ? "400px" : this.clientHeight);
    }
    复制代码

    17  z-index不起作用的 bug

    1)ie6下 首先讲讲第一种z-index无论设置多高都不起作用情况。这种情况发生的条件有三个:1、父标签position属性为relative;2、问题标签含有浮动(float)属性。
    2)所有浏览器:它只认第一个爸爸
    层级的高低不仅要看自己,还要看自己的老爸这个后台是否够硬。用术语具体描述为:
    父标签position属性为relative或absolute时,子标签的absolute属性是相对于父标签而言的。而在IE6下,层级的表现有时候不是看子标签的z-index多高,而要看它们的父标签的z-index谁高谁低。

    18  ie各个版本hack

    复制代码
    /*类内部hack:*/
        .header {_100px;}            /* IE6专用*/
        .header {*+100px;}        /* IE7专用*/
        .header {*100px;}            /* IE6、IE7共用*/
        .header {100px;}        /* IE8、IE9共用*/
        .header {100px9;}        /* IE6、IE7、IE8、IE9共用*/
        .header {330px9;}    /* IE9专用*/
    
    /*选择器Hack:*/
        *html .header{}        /*IE6*/ 
        *+html .header{}    /*IE7*/ 
    复制代码
     
    【作者】:@挨踢前端
    【出处】:http://www.cnblogs.com/duanhuajian/archive/2012/09/23/2699119.html
    【声明】:所有博文标题后加(share)的表示收集的他人优秀文章,其余的则为原创。欢迎转载,但请在显要位置显示本文链接,并保留本段声明,否则追究法律责任,谢谢!
  • 相关阅读:
    Polygon对象和Polyline对象的组成形式
    JavaScript脚本语言特色时钟
    洛谷——T P2136 拉近距离
    HDU——T 1498 50 years, 50 colors
    HDU——T 2119 Matrix
    HDU——T 1054 Strategic Game
    洛谷—— P2896 [USACO08FEB]一起吃饭Eating Together
    Django进阶之Form
    March 28 2017 Week 13 Tuesday
    March 27 2017 Week 13 Monday
  • 原文地址:https://www.cnblogs.com/alinaxia/p/6359636.html
Copyright © 2011-2022 走看看