开发者

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

开发者 https://www.devze.com 2023-01-01 08:08 出处:网络
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:

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

精彩评论

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