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