How to put scroll bar only for modal-body?
Solution 1:
You have to set the height
of the .modal-body
in and give it overflow-y: auto
. Also reset .modal-dialog
overflow value to initial
.
See the working sample:
http://www.bootply.com/T0yF2ZNTUd
.modal{
display: block !important; /* I added this to see the modal, you don't need this */
}
/* Important part */
.modal-dialog{
overflow-y: initial !important
}
.modal-body{
height: 80vh;
overflow-y: auto;
}
Solution 2:
If you're only supporting IE 9 or higher, you can use this CSS that will smoothly scale to the size of the window. You may need to tweak the "200px" though, depending on the height of your header or footer.
.modal-body{
max-height: calc(100vh - 200px);
overflow-y: auto;
}
Solution 3:
Problem solved with combine solution @carlos calla and @jonathan marston.
/* Important part */
.modal-dialog{
overflow-y: initial !important
}
.modal-body{
max-height: calc(100vh - 200px);
overflow-y: auto;
}