Set bootstrap modal body height by percentage

后端 未结 5 585
傲寒
傲寒 2021-01-31 03:09

I am trying to make a modal with a body that will scroll when the content becomes too large. However, I want the modal to be responsive to the screen size. When I set the max-he

5条回答
  •  孤街浪徒
    2021-01-31 03:27

    This worked for me

    .modal-dialog,
    .modal-content {
        /* 80% of window height */
        height: 80%;
    }
    
    .modal-body {
        /* 100% = dialog height, 120px = header + footer */
        max-height: calc(100% - 120px);
        overflow-y: scroll;
    }
    

    Fiddle: http://jsfiddle.net/mehmetatas/18dpgqpb/2/

提交回复
热议问题