2011-07-04 7 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