jQuery插件---兼容IE6的固定悬浮Postion:Fixed
制作一个兼容IE6中的Postion:Fixed固定悬浮效果,因为IE6不兼容Postion:Fixed,就做了一个Jquey插件。
使用方法:
$('#test').PositionFixed({x:200,y:200});
插件代码:
(function($) { jQuery.fn.PositionFixed = function(options) { var defaults = { css:'', x:0, y:0 }; var o = jQuery.extend(defaults, options); var isIe6=false; //is ie ? yes:ie no: not ie if($.browser.msie && parseInt($.browser.version)==6) isIe6=true; var html= $('html'); if (isIe6 && html.css('backgroundAttachment') !== 'fixed') { html.css('backgroundAttachment','fixed') }; return this.each(function() { var domThis=$(this)[0]; var objThis=$(this); if(isIe6) { var left = parseInt(o.x) - html.scrollLeft(), top = parseInt(o.y) - html.scrollTop(); 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)
效果图:
自己试一试
相关推荐
EdwardSiCong 2020-11-23
85477104 2020-11-17
hhanbj 2020-11-17
81427005 2020-11-11
seoppt 2020-09-13
honeyth 2020-09-13
WRITEFORSHARE 2020-09-13
84483065 2020-09-11
momode 2020-09-11
85477104 2020-08-15
83510998 2020-08-08
82550495 2020-08-03
tthappyer 2020-08-03
84901334 2020-07-28
tthappyer 2020-07-25
TONIYH 2020-07-22
tztzyzyz 2020-07-20
83510998 2020-07-18
81463166 2020-07-17