简体   繁体   中英

how to put dialog box position in the center of the page?

I want to open my dialog box at the center of the page, here is my code:

 $(function() {
   $('#app').button().click(function(){   //bind handlers
   $("#somediv").load('<?php echo CController::createUrl('jobs/apply', array('idJob'=>1)); ?>').dialog({modal:true}); 
   $("#somediv").dialog('option', 'position', 'center');
});
 });

Add the CSS rule: margin: 0 auto; to your dialog box. If you want it to pop over your web page, then place your dialog box inside a div that has the following attributes:

div.your-class {
    position: absolute;
    width: 100%;
}

Then add margin: 0 auto; to your dialog box div

From jquery docs - http://api.jqueryui.com/dialog/#option-position - that option you're trying to use is already in "center/center" position.

Default: { my: "center", at: "center", of: window }

You should look for a problem in your css files and/or use the answer provided by Valentin Mercier.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM