How jQuery puts elements in the middle of the screen
This article mainly introduces jQuery how to make elements in the middle of the screen, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let Xiaobian take you to understand.
Place the element in the middle of the screen
$(document) .ready (function () {jQuery.fn.center = function () {this.css ("position", "absolute"); this.css ("top", ($(window). Height ()-this.height ()) / 2percent $(window). ScrollTop () + "px"); this.css ("left", ($(window). Width ()-this.width ()) / 2percent $(window). ScrollLeft () + "px") Return this;} $("# id"). Center ();}); Thank you for reading this article carefully. I hope the article "how to make the element in the middle of the screen" shared by the editor will be helpful to everyone. At the same time, I also hope that you will support and pay attention to the industry information channel. More related knowledge is waiting for you to learn!