zoukankan      html  css  js  c++  java
  • css实现兼容各个浏览器的技巧

    IE6双倍边距问题
    在IE6中查看时,却会发现左侧外边距100像素,被扩大到200个像素,加上display: inline可解决;
    .floatbox {
      float: left;
       150px;
      height: 150px;
      margin: 5px 0 5px 100px;
      display: inline;
    }

    解决IE6不支持position:fixed;属性

    常规 position:fixed; 实现方法
      例:右下角 <div id="top">...</div> 这个 HTML 元素使用的 CSS 代码如下:
      #top{
        position:fixed;
        bottom:0;
        right:10px;
      }
      实现让 <div id="top">...</div> 元素固定在浏览器的底部和距离右边的10个像素。

    在 IE6中实现 position:fixed; 的办法
    #top{
      position:fixed;
      _position:absolute;
      bottom:0;
      right:10px;
      _bottom:auto;
      _top:expression(eval(document.documentElement.scrollTop+document.documentElement.clientHeight-this.offsetHeight-(parseInt(this.currentStyle.marginTop,10)||0)-(parseInt(this.currentStyle.marginBottom,10)||0))
    );
    在 _position:absolute; 中的 _ 符号只有 IE6 才能识别,目的是为了区分其他浏览器

    使元素固定在浏览器的顶部:
    #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,10)||0)-(parseInt(this.currentStyle.marginBottom,10)||0)));
    }
    这两段代码只能实现在最底部跟最顶部,可以使用 _margin-top:10px; 或者 _margin-bottom:10px; 修改其中的数值控制元素的位置

    position:fixed; 闪动问题

    用了上面的办法后,会发现:被固定定位的元素在滚动滚动条的时候会闪动。解决闪动问题的办法是在 CSS 文件中加入:
    *html{
      background-image:url(about:blank);
      background-attachment:fixed;
    }
    其中 * 是给 IE6 识别的。

    js解决ie兼容性

    使IE5,IE6兼容到IE7模式(推荐)
    <!--[if lt IE 7]>
    <script src="http://ie7-js.googlecode.com/svn/version/2.0(beta)/IE7.js" type="text/javascript"></script>
    <![endif]-->

    使IE5,IE6,IE7兼容到IE8模式
    <!--[if lt IE 8]>
    <script src="http://ie7-js.googlecode.com/svn/version/2.0(beta)/IE8.js" type="text/javascript"></script>
    <![endif]-->

    使IE5,IE6,IE7,IE8兼容到IE9模式
    <!--[if lt IE 9]>
    <script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"></script>
    <![endif]-->

    降级IE版本为7.0
    <meta http-equiv="X-UA-ompatible" content="IE=EmulateIE7" />
    另外;
    <meta http-equiv="X-UA-Compatible" content="IE=7" />

  • 相关阅读:
    村上春树的《海边的卡夫卡》与中日现实
    熊的甜蜜世界
    VS创建dll和调用dll
    DIRECTSHOW在VS2005中PVOID64问题和配置问题
    Vs 2008 解决方案的目录结构设置和管理
    SQL Server 2008中的代码安全(二):DDL触发器与登录触发器
    如何在自动SGA管理模式下调节参数设置
    将ORACLE数据库从归档改成非归档状态
    查看oracle数据库是否归档和修改归档模式(转)
    oracle TRANSLATE函数详解
  • 原文地址:https://www.cnblogs.com/jeffrey77/p/3057895.html
Copyright © 2011-2022 走看看