【发布时间】:2015-02-10 23:58:27
【问题描述】:
我遇到的问题是,我可以使用链接很好地创建对话框,并将对话框内的文本居中。我无法用标题和按钮做到这一点。我遇到的另一个问题是由于某种原因,我创建的按钮出现在对话框上但不起作用,我试图在浏览器调整大小后将我的 JQuery 对话框居中,但我也失败了。我想知道如何解决这个问题。任何帮助将不胜感激,谢谢大家。以下为jsfiddle链接:https://jsfiddle.net/robontrix/194Ljr30/
HTML:
<div id="dialog">
<p style="text-align:center"> Your computer use can be monitored by others! Consider using a public computer or a friend's computer. Please view more computer safety tips or escape to Google. Then more computer safety tips linked to a page with details about browser history, cache, search history, etc. and escape to Google linked to Google.</p>
<p style="text-align:center"> To learn more how to computer safety, click the following link: <br><a href="#">Safety Tips</a></br></p>
<!--Wording can be better just for the meantime-->
<p style="text-align:center"> If you are not safe, click the following link: <br><a href="#">Get Me Out of Here!</a></br></p>
</div>
<!--JQuery -->
<script src="http://code.jquery.com/jquery-1.9.1.js" type="text/javascript"></script>
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js" type="text/javascript"></script>
<script src="//code.jquery.com/jquery-1.10.2.js"></script>
<script>
$('#dialog').attr('title','Safety Warning!').dialog({
width : 700,
height: 350,
modal:true,
opacity:.7,
closeOnEscape: true,
draggable: false,
resizable: false,
buttons: { "Close": function() {
$(this).dialog("close");
}
}
});
$(window).resize(function() {
$('#dialog').dialog('option','position', 'center');
});
</script>
【问题讨论】:
-
我看到你用更多代码编辑了这个问题。当前发布的代码中绝对错误的一件事是您正在加载 2 个不同的 jquery 框架。
-
另外,除非您省略了一些您已经为此编写的样式表,否则您应该考虑从包含 jquery.ui.css 开始 - 这将使我的答案对您有用。