3

jquery UI 对话框如何跟随窗口滚动?

4

1 回答 1

3

这是可能的,但您需要覆盖基本的 jQueryUI 样式,因此请确保(在您的 CSS 中)您拥有:

.ui-dialog {
    position: fixed !important;
}

这是一个例子:

$(function() {
  $("#dialog-modal").dialog({
    height: 140,
    modal: true
  });
});
body {
  height: 3000px;
  }

p {
  margin-bottom: 300px;
  }

.ui-dialog {
  position: fixed !important;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<link href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" rel="stylesheet" />
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>


<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>


<!--these are here to help show that the dialogue is actually fixed -->
<p>A</p>
<p>B</p>
<p>C</p>
<p>D</p>
<p>E</p>
<p>F</p>

于 2013-10-14T10:04:07.430 回答