`

HTML IE6 纯CSS 解决 position fixed 的问题

阅读更多
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<style type="text/css">
.ie6fixed {border: 1px solid red; padding: 5px;}
/* 修正IE6振动bug */
* html,* html body{background-image:url(about:blank);background-attachment:fixed}
.ie6fixedLT{position:absolute;left:expression(eval(document.documentElement.scrollLeft));top:expression(eval(document.documentElement.scrollTop))}
.ie6fixedRT{position:absolute;right:expression(eval(document.documentElement.scrollLeft));top:expression(eval(document.documentElement.scrollTop))}
.ie6fixedLB{position:absolute;left:expression(eval(document.documentElement.scrollLeft+document.documentElement.clientWidth-this.offsetWidth)-(parseInt(this.currentStyle.marginLeft,10)||0)-(parseInt(this.currentStyle.marginRight,10)||0));top:expression(eval(document.documentElement.scrollTop+document.documentElement.clientHeight-this.offsetHeight-(parseInt(this.currentStyle.marginTop,10)||0)-(parseInt(this.currentStyle.marginBottom,10)||0)))}
.ie6fixedRB{position:absolute;right:expression(eval(document.documentElement.scrollLeft+document.documentElement.clientWidth-this.offsetWidth)-(parseInt(this.currentStyle.marginLeft,10)||0)-(parseInt(this.currentStyle.marginRight,10)||0));top:expression(eval(document.documentElement.scrollTop+document.documentElement.clientHeight-this.offsetHeight-(parseInt(this.currentStyle.marginTop,10)||0)-(parseInt(this.currentStyle.marginBottom,10)||0)))}
html>body .ie6fixedLT{position:fixed;left:0;top:0}
html>body .ie6fixedRT{position:fixed;right:0;top:0}
html>body .ie6fixedLB{position:fixed;left:0;bottom:0}
html>body .ie6fixedRB{position:fixed;right:0;bottom:0}
</style>
</head>
<body>
<div class="ie6fixedLT ie6fixed">IE6完美兼容position:fixed1</div>
<div class="ie6fixedRT ie6fixed">IE6完美兼容position:fixed2</div>
<div class="ie6fixedLB ie6fixed">IE6完美兼容position:fixed3</div>
<div class="ie6fixedRB ie6fixed">IE6完美兼容position:fixed4</div>
<div style="height: 3000px;"></div>
</body>
</html>

 

效果图:

 

 

 

 

 

 

 

  • 大小: 32.6 KB
1
1
分享到:
评论

相关推荐

    IE6下的纯CSS完美position:fixed实现

    NULL 博文链接:https://piziwang.iteye.com/blog/424862

    IE6中的position:fixed定位兼容性写法分享

    非IE6下的写法大家一般都清楚如何写;...}/* IE6 头部固定 */html .fixed-top{position:absolute;bottom:auto;top:[removed]eval&#40;document.documentElement.scrollTop&#41;);}/* IE6 右侧固定 */html .fixed-r

    ie6 position:fixed解决方案

    目前我所知的ie6下fixed的方案大概有纯css和expression+js两种,各有利弊。 1.纯css法 利用了ie6下html元素外面套的一个匿名元素,即 * ,利用选择器层级,可以定制ie6下的效果。代码如下 复制代码代码如下: * ...

    position:fixed在ie6的使用

    position:fixed在ie6的使用,hack的使用办法

    css3 position fixed固定居中问题解决方案

    一般我们会添加position:fixed,如下: 复制代码代码如下: #element{ position:fixed; margin:0 auto; } 但是这样做的结果就是,元素不居中了。这说明fixed使对象脱离了正常文档流。 解决方案: 复制代码代码...

    CSS表达式(expression)解决IE6 position:fixed无效问题

    IE6 position:fixed bug&lt;/title&gt; &lt;style&gt; *{padding:0;margin:0} p{height:2000px} #gs{border:1px solid #000;position:fixed;right:30px;top:120px} &lt;/style&gt; &lt;!–[if IE 6]&gt;

    IE6不兼容position:fixed属性的解决办法分享

    及上下两边,共四种位置的固定,与以往的教程不同的地方是,它使用CSS表达式来兼容IE5、IE6,且避免了js模拟时,拖动滚动条时出现抖动的问题,另外在IE5或者怪癖模式下也完全正常,没有任何问题。如果你有更好的方案...

    JS 滚动事件[removed]与position:fixed写兼容IE6的回到顶部组件

    IE6的兼容性问题主要出现在position:fixed上面,如何解决已经在《【CSS】IE6中的position:fixed问题与随滚动条滚动的效果》(点击打开链接)介绍过了。 下面具体说说如何利用JavaScript中的滚动事件[removed]实现...

    IE6 fixed的完美解决方案

    } 这个方法有一个bug未解决:在IE6下会把所有position:absolute都变成“浮动”的元素;还有使用js方法滚动滚动条时会出现对象闪烁,如下方法结合了CSS和js的办法,解决了以上的问题。 代码如下: &lt;!DOCTYPE html ...

    IE6下position fixed失效的解决方法(亲测有效)

    –[if IE 6]&gt; [removed] (function($) { jQuery.fn.Fixed = function(options) { var defaults = { x:0, y:0 }; var o = jQuery.extend(defaults, options); var isIe6 = !window.XMLHttpRequest; var html= $(...

    CSS Position(定位)

    CSS Position(定位) position 属性指定了元素的定位类型。 position 属性的五个值: fixed 定位 元素的位置相对于浏览器窗口是固定位置。 即使窗口是滚动的它也不会移动: 实例 p.pos_fixed { position:fixed; ...

    解决IE6、IE7、Firefox兼容比较简单的CSS Hack

    谁知道呢)看 第三排给IE6以及更老的版本看 最好的应用就是可以让IE6也“支持”position:fixed,而且,配合这个原理,可以做到不引入JavaScript代码(仅用IE6的expression),我这里有一个现成的页面,CSS如下写: ...

    ie6 fixed bug的解决方法 (css+js)

    复制代码代码如下: #fixed { position: absolute; top: 0; left: 0; width: 10em; height: 100%; } body &gt; #fixed { position: fixed; } #content { margin-left: 10em; background:red; height:800px; } 利用css...

    仿Lightbox效果(Windows关机效果),div覆盖,锁定页面及IE 6实现position:fixed;

    NULL 博文链接:https://clfsw.iteye.com/blog/657170

    CSS position属性absolute relative等五个值的解释

    其中absolute和relative是最常用的,fixed用得也比较多(其中IE6并不支持fixed)。 1、absolute(绝对定位) absolute是生成觉对定位的元素,脱离了文本流(即在文档中已经不占据位置),参照浏览器的左上角通过top,...

    CSS行为expression轻松实现IE6无抖动固定定位

    概述: IE6不支持固定定位(position:fixed)是众所周知的事情,所以我们要想在IE6做出固定定位的效果就只能用JS,但是用js会出现“跳动”的效果,所以有没有不用JS而且不跳动的办法呢?这是怎么做到的呢?今天说说...

    css兼容IE678的底部固定浮动层

    用css实现div固定在屏幕底部,不随垂直滚动条接动而闪动,很好的实现在ie下的浮动效果,IE6 position:fixed

Global site tag (gtag.js) - Google Analytics