javascript - How to make header and footer of Modal fixed while allowing the Modal content alone to scroll? - Stack Overflow

I have been playing around with the Modal ponent and I noticed that long content in a Modal window make

I have been playing around with the Modal ponent and I noticed that long content in a Modal window makes the whole modal body scroll instead of just the content inside the Modal.

Is there any way to make the content alone scroll while keeping the header and footer of the Modal ponent fixed?

I require something similar to how Material-UI Dialog ponent's Paper scroll works.

Check the button labeled scroll=Paper.

I have been playing around with the Modal ponent and I noticed that long content in a Modal window makes the whole modal body scroll instead of just the content inside the Modal.

Is there any way to make the content alone scroll while keeping the header and footer of the Modal ponent fixed?

I require something similar to how Material-UI Dialog ponent's Paper scroll works.

Check the button labeled scroll=Paper.

Share Improve this question edited Jun 23, 2019 at 19:25 Dennis Vash 54k12 gold badges117 silver badges132 bronze badges asked Jun 23, 2019 at 19:09 gameboynintendocolorgameboynintendocolor 352 silver badges5 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 6

There is no official way to do this, I believe because it's pretty trivial.

You need to define the Modal children scrollable, for example defining a Card with overflow and height.

<Card bordered={false} style={{ overflow: 'auto', height: '50vh' }}>

Material-UI Dialog doing just that behind the scenes.

function FixedModal() {
  return (
    <Modal visible={true} title={'Title'} footer={'Footer'}>
      <Card bordered={false} style={{ overflow: 'auto', height: '50vh' }}>
        {[...new Array(50)]
          .map(
            () => `Cras mattis consectetur purus sit amet fermentum.
Cras justo odio, dapibus ac facilisis in, egestas eget quam.
Morbi leo risus, porta ac consectetur ac, vestibulum at eros.
Praesent modo cursus magna, vel scelerisque nisl consectetur et.`
          )
          .join('\n')}
      </Card>
    </Modal>
  );
}

Demo:

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744132876a4559919.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信