我希望我的 JavaScript 窗口(日期选择器)位于所有窗口的顶部(直到我选择日期或关闭它)。需要指导
最佳答案
如果日期选择器窗口引用 html 中的元素,那么应该这样做。
日期 div 的 CSS
z-index: 20;
其他div的CSS
z-index: 10;
然后您只需显示或隐藏日期 div,它就会始终位于顶部。
你需要它显示但不在顶部,将z-index
更改为比其他div低的值
如果您无权访问所有 div 的 z-index 设置,请查看此帖子,How can you figure out the highest z-index in your document? , 看看你如何尝试找到最高的或简单地将你的日期选择器设置为即 z-index: 10000
。
更新
如果你想要一个模式对话框弹出 div,这是一个开始
演示:http://codepen.io/anon/pen/BLvcK
jQuery(来源:http://jqueryui.com/dialog/#modal)
<link rel="stylesheet" href="//code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css">
<script src="//code.jquery.com/jquery-1.9.1.js"></script>
<script src="//code.jquery.com/ui/1.10.4/jquery-ui.js"></script>
<link rel="stylesheet" href="/resources/demos/style.css">
<script>
$(function() {
$( "#dialog-modal" ).dialog({
height: 140,
modal: true
});
});
</script>
HTML
<div id="dialog-modal" title="Basic modal dialog">
<p>Adding the modal overlay screen makes the dialog look more prominent because it dims out the page content.</p>
</div>
<p>Sed vel diam id libero <a href="http://example.com">rutrum convallis</a>. Donec aliquet leo vel magna. Phasellus rhoncus faucibus ante. Etiam bibendum, enim faucibus aliquet rhoncus, arcu felis ultricies neque, sit amet auctor elit eros a lectus.</p>
关于javascript - 如何使 javascript 窗口位于所有其他窗口之上?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22006393/