在单个div上启用滚动?

gda*_*nko 4 html javascript css jquery jquery-ui

我的布局看起来像这样:

<html>
  <head>
    stuff here
  </head>
  <body>
    <div id="master">
      <div id="toolbar">
        <input type="text" id="foo">
      </div>
      <div id="content">
        a whole bunch of content in here
      </div>
    </div>
  </body>
</html>
Run Code Online (Sandbox Code Playgroud)

'#master'是jquery UI对话框的容器.我希望'#content'div的内容可以滚动,但'#toolbar'不能滚动.这是否适用于jquery UI的对话框?

Jos*_*ell 10

只需使用css规则:

#content { overflow: auto; height: [desired height] }
Run Code Online (Sandbox Code Playgroud)

如果模态具有动态高度,则可能需要使用jQuery.在那种情况下,open您可以设置内部容器高度.就像是:

open: function(){
    var modalHeight = $('#master').height();
    $('#content').height(modalHeight - [footer and title]);
}
Run Code Online (Sandbox Code Playgroud)