Bootstrap 4 Table With The Scrollable Body And Header Fixed
Solution 1:
Can set fixed header by using position: sticky
.
Check the sample code.
Here set the height to the main container.
.table-responsive{height:400px;overflow:scroll;}
Set the postion sticky to the tr-> th.
theadtr:nth-child(1) th{background: white; position: sticky;top: 0;z-index: 10;}
Solution 2:
Try using flex, it should be compatible with table-responsive
:
table {
display: flex;
flex-flow: column;
width: 100%;
}
thead {
flex: 00 auto;
}
tbody {
flex: 11 auto;
display: block;
overflow-y: auto;
overflow-x: hidden;
}
tr {
width: 100%;
display: table;
table-layout: fixed;
}
Hope this will help
Solution 3:
add display:block
to the table to fix this
tbody{height: 400px; overflow-y: scroll;display:block;}
th { position: sticky; top: 0; }
Solution 4:
use position : sticky at and top : 0
th {
background: white;
position: sticky;
top: 0; /* Don't forget this, required for the stickiness */
}
full example can be found here: https://css-tricks.com/position-sticky-and-table-headers/
Has A Class, Add Class To Table Cell |
Let's say I have the following html: …
WebRTC Video Constraints Not Working
I'm trying to get a lower resolution from the webcam na…
HasClass Doesn't Work In My Js Code?
I want to use hasClass in the following code, but that does…
I am relatively new to Javascript/Ajax. When the user click…
Highcharts Donutchart: Avoid Showing Duplicate Legend With Nested Charts
I am trying to represent nested data using Highcharts Donut…
How Do I Use Data From Vue.js Child Component Within Parent Component?
I have a form component where I use a child component. I wa…
Logic For The Next Button For The Questionnaire?
I am beginner in AngularJS and facing some issues. I am try…
Assignment To Property Of Function Parameter (no-param-reassign)
I have this function and while I have this working nicely, …
I am making a web application using nodejs and angular cli …
How To Show Website Preloader Only Once
I added a preloader to my website and the preloader animati…
|
---|
Post a Comment for "Bootstrap 4 Table With The Scrollable Body And Header Fixed"