开发者

How to find the center point on the page with JavaScript?

How can I find the (x,y) point of the center of the viewable area of the browser?

I am using jQuery, if there are any good jQuery helper functions for th开发者_运维知识库is.


Like this:

var x = $(window).width() / 2;
var y = $(window).height() / 2;

If you want the center point of the whole document (not just the viewable area), you can use $(document) instead.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜