基本上我做了一個彈出窗口,並將其定位在我的頁面頂部,這很好,但顯然沒有爲底部的頁腳鏈接工作,因爲它只是顯示在頂部。無論在哪裏彈出,都很難在中心彈出顯示
我希望能夠讓它在中心彈出,不管鏈接被按下的位置,我希望這是有道理的。
我試過搜索互聯網而不是任何有用的教程如何解決這個問題。
所以我轉向了Stackoverflow的力量。
視覺: http://madaxedesign.co.uk/
的Jquery:
$('a.contact , a.contact_footer, a.contact_text').click(function() {
$("#popup").load("contact.php");
// Getting the variable's value from a link
var
show = $('#popup').css('display', 'block'),
popup = $(this).attr('href');
//Fade in the Popup and add close button
$(popup).fadeIn(300);
//Set the center alignment padding + border
var popMargTop = ($(popup).height() + 24)/2;
var popMargLeft = ($(popup).width() + 24)/2;
$(popup).css({
'margin-top' : -popMargTop,
'margin-left' : -popMargLeft
});
// Add the mask to body
$('body').append('<div id="mask"></div>');
$('#mask').fadeIn(300);
return false;
});
// When clicking on the button close or the mask layer the popup closed
$('a.cross, #mask').live('click', function() {
$('#mask , #popup').fadeOut(300 , function() {
$('#mask').remove();
});
return false;
});
如果您需要了解更多信息請諮詢。
你試過使用$(window).scrollTop()嗎?我用它來處理類似的情況。這裏的API:http://api.jquery.com/scrollTop/ – SamHuckaby 2013-04-24 19:56:48
ooooo不,我沒有,但這是一個很好的小竅門。現在會有一個戲。 – MaxwellLynn 2013-04-24 20:00:46