In the pop-up window, do not center the display ?, Center display in the pop-up window

Source: Internet
Author: User

In the pop-up window, do not center the display ?, Center display in the pop-up window

Preface: Is the displayed dialog box not centered? Have you used the standard center algorithm or the display is not centered? Where is TM? In the previous article, I introduced the jquery weebox summary. weebox is definitely a good choice in the pop-up box. Now this is a wonderful problem, that is, it is not centered.

Effect

Note: do not care about the display of this page.

Pop-up method
<Div class = "blank"> </div> <div class = "dlmain" style = "overflow: hidden; width: pixel; "> <div class =" f_l dlr "style =" height: 350px; width: 554px; "> <div class =" dlr1 "> <span class =" f_l "> User Logon </span> <span class =" f_r "style =" font-size: 14px; color: # 8c8c8c; line-height: 14px; margin-top: 16px; "> no account yet? <A href = "" style = "color: # 0196db; "> register </a> </span> </div> <div class =" blank0 "> </div> <form id =" user_login_form "name =" user_login_form "action = "$ {ctx}/login"> <div class = "control-group"> <label class = "control-label"> account </label> <div class =" control-text "> <div class =" pr f_l "> <input type =" text "name =" username "id =" username "value =" "class =" textbox" /> <span class = "holder_tip"> enter the member account </span> </div> </ Div> <div class = "blank0"> </div> <div class = "control-group"> <label class = "control-label"> password </label> <div class = "control-text"> <div class = "pr f_l"> <input type = "password" name = "password" id = "password" value = "" class = "textbox"/> <span class = "holder_tip"> enter the logon password </span> </div> <a href = "" style = "color: # 1184df; font-size: 13px; "> forgot password? </A> </div> <div class = "blank0"> </div> <div class = "blank0"> </div> <div class = "control-group tl"> <label class = "control-label"> </label> <label class = "ui_checkbox" rel = "carry_type"> <input type = "checkbox ""value =" 1 "name =" auto_login "checked =" checked "/> remember me (next automatic login) </label> </div> <div class = "blank0"> </div> <div class = "control-group"> <label class = "title control-label"> </label> <input type = "button" value = "login" name = "submit_form" class = "ui-button theme_bgcolor" id = "btn_do_login" onclick = "do_login_user (); "/> </div> </form> </div> <div class =" blank "> </div>

This page is very bad.

Then let's see how to call her!

Function show_pop_login () {$. weeboxs. open (common. ctx + "/pages/login. jsp? Ctl = ajax & act = login ", {boxid: 'pop _ user_login ', contentType: 'ajax', showButton: false, showCancel: false, showOk: false, title: 'Member login ', width: 700, type: 'wee'}); // $. showErr ("aaaaaaaaaa ");}

You can directly put the page path in the open method.

Then let's look at the center display algorithm:

this.setCenterPosition = function() {            var wnd = $(window), doc = $(document),                pTop = doc.scrollTop(), pLeft = doc.scrollLeft(),                minTop = pTop;              pTop += (wnd.height() - self.dh.height()) / 2;            pTop = Math.max(pTop, minTop);            pLeft += (wnd.width() - self.dh.width()) / 2;            self.dh.css({top: pTop, left: pLeft});        }

You think this is not centered. Why?

So far, you still don't tell me the answer. When I used firebug to debug this code string, I found wnd. height () has more than 1400, and my screen is not so big at most, that is, more than 900.

Y. It's off duty. I don't want to talk about it anymore.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

If it is

In this way, the obtained height is problematic.

Then you need to place

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

Conclusion: Let's talk about this!

Copyright Disclaimer: All blogs on this site are original articles of qing_gee. If you need to reference and repost, you only need to specify the source and original link.

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.