javascript - 如何使 javascript 窗口位于所有其他窗口之上?

标签 javascript jquery css

我希望我的 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/

相关文章:

javascript - 临时全局变量/函数和原型(prototype)重写来编写 JS DSL

javascript - 多组 jQuery 文本旋转器不太工作。

javascript - jQuery 查找表行但忽略子表中的行

javascript - 如何在 Bootstrap 中动态添加行

html - 将 SVG 属性添加到类

html - CSS 将表重置为默认值

javascript - Render 方法不会重新渲染在构造函数中初始化的元素

javascript - AngularJS - Kendo UI 应用程序在 "Evaluate Script"中花费很长时间

jquery - 尝试在网站加载时隐藏图像,但有一个按钮显示它

html - 内容边框未在任何浏览器中显示!