Center Align Window and dialog box

Source: Internet
Author: User

Web front-end windows, dialog boxes and other interfaces, often need to center alignment.
In the jquery Easyui Medium window component, there are usually width widths, height heights, distance left from the container, and distance from the top of the container top,4 parameters.


In the implementation process, the main is the dynamic or static setting these 4 parameters.


The height of the current window: $ (window). Width ()
Width of the current window: $ (window). Width ()


If you are getting the parent window, use Window.parent.


Width: is a method, not a property.


Here is an example:
var windowwidth =$ (window.parent). width ();
var windowheight=$ (window.parent). Height ();
var width=380;
var height=windowheight-200;
var top= (windowheight-height)/2;
var left= (windowwidth-width)/2;
var $win = $ (' #preView '). Window ({
Content: ' <iframe scrolling= ' yes ' frameborder= "0" src= "'
+ href
+ ' "style=" width:100%;height:98%; " ></iframe> ',
Title: ' App Preview ',
Width:width,
Height:height,
Top:top,
Left:left,
});


$win. Window (' open ');

Width: Fixed width 380
Height: Window height-Fixed 200
Distance from top: (window Height-height of dialog box)/2, center alignment
Distance to the left: center alignment


In 2 kinds of screens, try, no problem ~

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Center Align Window and dialog box

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.