`
javatoyou
  • 浏览: 1018568 次
  • 性别: Icon_minigender_2
  • 来自: 北京
文章分类
社区版块
存档分类
最新评论

在Jquery中让一个容器div显示在屏幕正中央

 
阅读更多
非常简单就实现了,代码不用解释,很容易懂的

//request data for centering
var windowWidth = document.documentElement.clientWidth;
var windowHeight = document.documentElement.clientHeight;
var popupHeight = $("#popupContact").height();
var popupWidth = $("#popupContact").width();
//centering
$("#popupContact").css({
"position": "absolute",
"top": windowHeight/2-popupHeight/2,
"left": windowWidth/2-popupWidth/2
});
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics