Skip to content

Instantly share code, notes, and snippets.

@bintangmuh
Created May 21, 2024 03:00
Show Gist options
  • Save bintangmuh/94010799dd6226da1ec0d2151473913d to your computer and use it in GitHub Desktop.
Save bintangmuh/94010799dd6226da1ec0d2151473913d to your computer and use it in GitHub Desktop.
Fixed first coloumn when table scroll horizontaly
/* source: https://dev.to/nicolaserny/table-with-a-fixed-first-column-2c5b */
/* work with bootstrap table css */
/* make the first coloumn of the (row head and body) sticky */
.table-sticky>tr>th:first-child,.table-sticky>tr>td:first-child {
position: sticky;
left: 0;
background-color: inherit;
}
/* change the background color please, otherwise it will transparent */
.table-striped .table-sticky>tr:nth-of-type(odd) td:first-child {
background-color: rgba(242, 242, 242);
}
.table-striped .table-sticky>tr:nth-of-type(even) td:first-child {
background-color: white;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment