0
我遇到了模态窗口定位问题。我一直在尝试使用$(document).height()和$(window).height(),它并没有给我我想要的东西。如果我在首页上,这会给我正确的定位,但是如果我在我的页面上向下滚动。该模式将自己定位在首页,而不是我在浏览器中查看的位置。模态窗口定位帮助!
有人请帮我:)这方面的工作了很长时间
谢谢
的jQuery:
//Get the screen height and width
var maskHeight = $(document).height();
var maskWidth = $(window).width();
//Set heigth and width to mask to fill up the whole screen
$('#mask').css({'width':maskWidth,'height':maskHeight});
//transition effect
$('#mask').fadeIn(1);
$('#mask').fadeTo("fast",0.8);
//Get the window height and width
var winH = $(window).height();
var winW = $(window).width();
//Set the popup window to center
id.css('top', (winH - id.outerHeight())/2);
id.css('left', ' (winW- id.outerWidth())/2);
//transition effect
id.show();
CSS
.imageBox .window {
left:0;
top:0;
text-align:center;
position:absolute;
display:none;
z-index:9999;
padding:20px;
}
我不想使用位置:固定;因为如果模态窗口的高度太大,我将无法滚动到窗口视图之外的内容
甜蜜的感谢!这就是我需要的 – hellomello