[英]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;
添加CSS规则:
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内:
div.your-class {
position: absolute;
width: 100%;
}
Then add margin: 0 auto;
然后添加
margin: 0 auto;
to your dialog box div
到对话框
div
From jquery docs - http://api.jqueryui.com/dialog/#option-position - that option you're trying to use is already in "center/center" position. 从jquery文档-http: //api.jqueryui.com/dialog/#option-position-您要使用的选项已经位于“ center / center”位置。
Default: { my: "center", at: "center", of: window }
默认值:{my:“ center”,位于:“ center”,of:window}
You should look for a problem in your css files and/or use the answer provided by Valentin Mercier. 您应该在CSS文件中查找问题和/或使用Valentin Mercier提供的答案。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.