Get the App
SLTechnology News&Howtos  ›  Development  › 

How jQuery puts elements in the middle of the screen

Shulou Source: shulou.com Published: 2022-06-01 04:01:13 10月31日 Update

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!

Tags: Articles location elements screen value interest at the same time more friends knowledge editing industry information information channels channels references learning help support Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Huawei Xiaomi Shulou Information Redmi Microsoft