I have a table that displays inside a panel that is inside modal . Since the table is relatively large, I would like to limit its rows to say 5 so that the modality does not become scrollable. I looked at SO and google and everywhere I see that I need to set overflow-y:auto or overflow-y:scroll in order for it to work, but in my case it is not. I also set an arbitrary height of 400 pixels and position: absolute. This allowed us to scroll through the table, but now the panel is closed with <thead> , and the body of the table is displayed outside the panel. What is the fix for this?
My code snippet:
<div class="modal fade"> <div class="modal-dialog " > <div class="modal-content"> <div class="modal-body"> <div class="panel panel-default"> <div class="panel-body"> <table class="table table-bordered> <thead> [........] </thead> <tbody style="overflow-y:auto; height:400px; position:absolute> [.......] </tbody> </table>
[... the rest of </div> s ...]
EDIT
Thanks for answers. Is there a way to narrow the scrollbar to <tbody> alone so that <thead> remains stationary?
source share