悬浮框增加屏幕绝对定位

问题:貌似IE6不兼容
This commit is contained in:
sw 2014-11-18 11:18:00 +08:00
parent 90f5cd2e60
commit 3ac023e7a5
1 changed files with 4 additions and 5 deletions

View File

@ -33,12 +33,11 @@
var xstep=1; // 移动步长此参数越小移动越平滑最小值为1
var delay_time=60; // 每步的时间间隔,此参数越小,移动速度越快
var YY=0;
var screen_height = $(window).height(); //浏览器当前窗口文档的高度
var screen_width = $(window).width(); //浏览器当前窗口文档的宽度
window.setInterval(function(){move();},delay_time);
function move()
{
var screen_height = $(window).height(); //浏览器当前窗口文档的高度
var floatpoint_height = $("#floatpoint").height();
YY += xstep;
if(YY <= 0){xstep = 1; YY = 0;} //如果浮动层超出了上界,则设定移动方向为向下;并设定层的位置为正好在上界处
@ -47,9 +46,9 @@
xstep = -1;
YY=(screen_height-floatpoint_height);
}
$("#floatpoint").css("top",YY);
$("#floatpoint").css("margin-top",YY);
}
function change_size(){var body_width = $("#top-menu").width(); $("#floatpoint").css("left",screen_width/2+body_width/2+10);}
function change_size(){var screen_width = $(window).width();var body_width = $("#top-menu").width(); $("#floatpoint").css("left",screen_width/2+body_width/2+10).css("position", "fixed");}
$(document).ready(function(){change_size();});
$(window).resize(function(){screen_width = $(window).width();change_size();});
$(window).resize(function(){change_size();});
</script>