2011-07-04 6 views
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; 
} 

私はしたくありません使用する位置:固定;モーダルウィンドウの高さが大きすぎると、ウィンドウビューの外にあるコンテンツにスクロールすることはできません

答えて

1

スクロールしてスクロールして計算に含めると、

var pixelsScrolled = $(document).scrollTop(); 

これが役に立ちます。乾杯

+0

甘いありがとう!それは私が必要なものです – hellomello