Home > Web Front-end > JS Tutorial > body text

The pop-up prompt box based on jquery is always in the center of the window (similar to the effect of the alert pop-up box)_jquery

WBOY
Release: 2016-05-16 18:01:35
Original
1087 people have browsed it

The principle is very simple:
Get the width and height of the current screen (form), because the form sizes of different browsers are different. With this, the vertically centered coordinates can be calculated. But how can it still be vertically centered after sliding the scroll bar? At this time, you need to get the height of the current form from the top of the page and add it to the y-axis coordinate just now.
$(document) gets the entire web page, $(window) gets the current form, this needs to be clarified.
Finally, just assign the obtained coordinates to the form. The form itself is absolutely positioned, so it can naturally go to the middle of the form.
Specific code:

Copy code The code is as follows:





< title>Test that the pop-up confirmation box is always located in the middle of the window

< script type="text/javascript" src="jquery-1.6.1.min.js">




Pop-up confirmation box always Test located in the middle of the window



Are you sure you want to delete it?







Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!