我遇到一个小问题,我的jQuery
警告框位于页面的中心以外的任何位置。只要我的按钮功能开始,它将其设置为页面的中心。jQuery警报箱固定位置问题?
我想在div
上使用一个班级给它一个固定的位置来尝试改变这个,但仍然没有快乐有人知道我可能会在这里出错吗?
谢谢。
function myFunction() {
$("#dialog1").dialog("open");
}
$(function() {
$("#dialog1").dialog({
autoOpen: false,
show: {
effect: "puff",
duration: 300
},
hide: {
effect: "clip",
duration: 500
}
});
$("#opener").on("click", function() {
$("#dialog1").dialog("open");
});
});
.alertBox {
position: fixed;
bottom: 0;
right: 0;
}
<html>
<head>
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
</head>
<div id="dialog1" class="alertBox" title="Alert Title!">
<p>Alert Message Example</p>
</div>
<body>
<button onclick="myFunction()">OPEN ALERT</button>
</body>
</html>
[位置jQuery的对话框(可能的重复https://stackoverflow.com/questions/15716317/position-jquery -dialog-box) – Dasma
也许你知道这一点,但#dialog1 div不在body标签中。 – wpalmes