在网上找了好久,终于找到一种亲测有效的解决方法。

<!--[if IE 6]>
<script type="text/javascript">
(function($) {      jQuery.fn.Fixed = function(options) {  var defaults = {x:0,  y:0  };  var o = jQuery.extend(defaults, options);  var isIe6 = !window.XMLHttpRequest;var html= $('html');  if (isIe6 && html.css('backgroundAttachment') !== 'fixed') { //防止抖动 html.css('backgroundAttachment','fixed').css('backgroundImage','url(about:blank)');};return this.each(function() {  var domThis=$(this)[0];  var objThis=$(this);  if(isIe6){objThis.css('position' , 'absolute');domThis.style.setExpression('left', 'eval((document.documentElement).scrollLeft + ' + o.x + ') + "px"');  domThis.style.setExpression('top', 'eval((document.documentElement).scrollTop + ' + o.y + ') + "px"'); } else {  objThis.css('position' , 'fixed').css('top',o.y).css('left',o.x);  }});  };
})(jQuery)
</script>
<![endif]-->

调用方法如下:

<!--[if IE 6]>
<script type="text/javascript">
$(function(){
$('.float').Fixed({x:800,y:200});
});
</script>
<![endif]-->

fixed一般应用有两种情况。

一,居中的弹层:

<!--[if IE 6]>
<script type="text/javascript">
$(function(){
//centerX和centerY是可视窗口的高和宽,需要减去自身的的宽度或高度的一半才能居中
var screenHeight=document.documentElement.clientHeight,screenWidth=document.documentElement.clientWidth,floatHeight=$('.float').height(),floatWidth=$('.float').width();$('.float').Fixed({x:(screenWidth-floatWidth)/2,y:(screenHeight-floatHeight)/2
    });
});
</script>
<![endif]-->

二,靠右的弹层,类似于回到顶部等:

<!--[if IE 6]>
<script type="text/javascript">
$(function(){
//centerX和centerY是可视窗口的高和宽,高度自定义,宽度为屏幕宽度-浮层宽度
var screenHeight=document.documentElement.clientHeight,screenWidth=document.documentElement.clientWidth,floatHeight=$('.float').height(),floatWidth=$('.float').width();$('.float').Fixed({x:screenWidth-floatWidth,y:300});
});
</script>
<![endif]-->

这下就妥妥的了。

转载于:https://www.cnblogs.com/xiaoyouzi/p/3919249.html

IE6下fixed失效的解决方法相关推荐

  1. margin-top失效的解决方法

    异常处理汇总-前端系列 http://www.cnblogs.com/dunitian/p/4523015.html 我的是属于这种情况 按照网上的说法,我就是这个现象了 两个层box1和box2,b ...

  2. win11快捷键失效怎么办 windows11快捷键失效的解决方法

    我们经常会使用快捷键来帮助我们快速地打开所需要的应用,提高使用效率,但是有小伙伴在使用的时候发现快捷键失效,那么遇到这种情况要怎么办呢?下面就和小编一起来看看有什么解决方法吧.更多windows11系 ...

  3. Win10企业版任务栏上搜索功能失效的解决方法

    Win10企业版任务栏上搜索功能失效的解决方法 1. 系统版本与问题描述 ① 系统版本 ② 问题描述 2. 问题分析与解决方法 ① 问题分析 ② 解决方法 1. 系统版本与问题描述 ① 系统版本 系统 ...

  4. android keytool 不是内部命令或外部命令在 (win7下不能用的解决方法)

    android 关于MD5指纹中 keytool在win7下不能用的解决方法 只要在cmd中执行如下命令即可:注意C:\Users\Administrator\.android\debug.keyst ...

  5. Quill编辑器IOS下无法获取焦点的解决方法

    Quill编辑器IOS下无法获取焦点的解决方法 参考文章: (1)Quill编辑器IOS下无法获取焦点的解决方法 (2)https://www.cnblogs.com/slmk/p/8618296.h ...

  6. nvm 装 nodejs 重启终端失效的解决方法

    nvm 装 nodejs 重启终端失效的解决方法 参考文章: (1)nvm 装 nodejs 重启终端失效的解决方法 (2)https://www.cnblogs.com/zhangkunweb/p/ ...

  7. 联想笔记本Win10 F1-F12失效的解决方法

    联想笔记本Win10 F1-F12失效的解决方法 参考文章: (1)联想笔记本Win10 F1-F12失效的解决方法 (2)https://www.cnblogs.com/expiator/p/633 ...

  8. Eclipse在高分屏下图标过小的解决方法

    Eclipse在高分屏下图标过小的解决方法 参考文章: (1)Eclipse在高分屏下图标过小的解决方法 (2)https://www.cnblogs.com/wenziii/p/5599310.ht ...

  9. Python TimedRotatingFileHandler 多进程环境下的问题和解决方法

    Python TimedRotatingFileHandler 多进程环境下的问题和解决方法 原文:https://my.oschina.net/lionets/blog/796438 Python ...

最新文章

  1. 憋个大招!一起“干完”这份300页1000道面试题
  2. wxWidgets:容器类
  3. MicroStation V8i简体中文版中文字体乱码解决办法
  4. Unity AssetBundles and Resources指引 (三) AssetBundle基础
  5. 基于JAVA+SpringMVC+Mybatis+MYSQL的在线超市管理系统
  6. 第一个关于selenium项目
  7. 学术之路如何走好?过来人的10条建议!
  8. 热烈庆祝blog开通
  9. 力软下拉框多选_力软敏捷开发框架操作手册V7.06
  10. JsessionId简介与过滤
  11. php数组中随机抽取,PHP 数组中随机抽取一些元素_PHP教程
  12. Python爬虫爬取滚动新闻
  13. 驾驶车辆 档位与油门的关系
  14. 10分钟学会go module
  15. Open3D-GUI系列教程(五)鼠标事件(拾取顶点)
  16. 【拼多多】拼多多顶级佣金助手(直连拼多多官方,无上级抽佣,各种免单)...
  17. 3D物联网大数据可视化制作平台
  18. 01【刘立刚图形学笔记】_图形学整体概述
  19. Shell内建命令之echo、local、logout
  20. 32位系统装8g内存条?能用吗

热门文章

  1. 从jquery源码中学习一些技巧
  2. [原] 利用Radix树作为Key-Value 键值对的数据路由
  3. Tomcat 相关配置
  4. Eclipse 的IOConsole Updater error
  5. C/C++中extern关键字
  6. TraceRoute原理
  7. apache php linux 安全,Centos7环境下的apache和php安全设置及优化 | 彬菌
  8. SQL Server 字符串操作
  9. redis windows
  10. Configuring the Java Virtual Manager (JVM)