0
我有一个弹出在我的页面中间弹出一个js弹出。问题是,当用户向下滚动到页面底部并点击按钮触发弹出时,弹出窗口将出现在顶部而不是屏幕中间(因为用户已经向下滚动,所以他/她不在页面的中间)。使JavaScript弹出中间的屏幕,而不是页面中间
我想要的是,无论用户在哪里查看,弹出窗口都会位于用户的屏幕中间。
function centerPopup(){
var windowWidth = document.documentElement.clientWidth;
var windowHeight = document.documentElement.clientHeight;
var popupHeight = $(".popupContent").height();
var popupWidth = $(".popupContent").width();
$(".popupContent").css({
"position": "absolute",
"top": windowHeight/2-popupHeight/2,
"left": windowWidth/2-popupWidth/2
});
//this is needed for ie6
$(".backgroundPopup").css({ "height": windowHeight });
}
或者是有可能有一个弹出触发弹出下面的按钮?
只是禁用/启用scrollig,当弹出窗口显示 – Sarath
使用'位置:fixed'代替。 – JJJ
我明白了,谢谢兄弟。放大时使用触摸屏设备的用户会感到讨厌吗?你有一些jQuery的示例代码,直接弹出按钮下方? –