简体   繁体   English

如何将滚动添加到 react-bootstrap Modal.Body

[英]How to add scroll into react-bootstrap Modal.Body

I'm using react-bootstrap modal .我正在使用react-bootstrap modal

How can I make only body to scroll and not all the page?如何仅滚动正文而不滚动整个页面?

  <Modal.Dialog>
    <Modal.Header>
      <Modal.Title>Modal title</Modal.Title>
    </Modal.Header>

    <Modal.Body>One fine body...</Modal.Body>

    <Modal.Footer>
      <Button>Close</Button>
      <Button bsStyle="primary">Save changes</Button>
    </Modal.Footer>
  </Modal.Dialog>

Thanks to Amit answer .感谢Amit 的回答

The first solution using only styles would be the following:仅使用样式的第一个解决方案如下:

  <Modal.Dialog>
    <Modal.Header>
      <Modal.Title>Modal title</Modal.Title>
    </Modal.Header>

    <Modal.Body style={{
      maxHeight: 'calc(100vh - 210px)',
      overflowY: 'auto'
     }}
    >
     One fine body...
    </Modal.Body>

    <Modal.Footer>
      <Button>Close</Button>
      <Button bsStyle="primary">Save changes</Button>
    </Modal.Footer>
  </Modal.Dialog>

There is a new way to implement that behavior using the react-bootstrap itself:有一种使用react-bootstrap本身来实现该行为的新方法:

<Modal
  scrollable={true}
  ....
>
  ....
</Modal>

Documentation: https://react-bootstrap.netlify.app/components/modal/#modals文档: https : //react-bootstrap.netlify.app/components/modal/#modals

you can add scrallable to Modal tag like this您可以像这样将可滚动添加到 Modal 标签

<Modal scrollable={true} >
</Modal>

you can get in detail here: https://react-bootstrap.netlify.app/components/modal/#modals你可以在这里获得详细信息: https : //react-bootstrap.netlify.app/components/modal/#modals

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM