I want to create a display flex table with sticky headers. I don't know why but my table loses it's position:sticky nature when I set displays of the table structure to flexbox.
My code (scss):
.talbe-container{
position: absolute;
top: 0;
bottom: 0;
right: 0;
left: 0;
overflow-y: auto;
.table{
width: 100%;
display: flex;
flex-flow: column nowrap;
flex: 1 1 auto;
thead{
tr{
display: flex;
flex-flow: row nowrap;
align-self: flex-start;
th{
top: 0;
position: sticky;
display: flex;
flex-flow: row nowrap;
flex-grow: 1;
flex-basis: 0;
white-space: nowrap;
z-index: 100;
}
}
}
tbody{
tr{
display: flex;
flex-flow: row nowrap;
td{
display: flex;
flex-flow: row nowrap;
flex-grow: 1;
flex-basis: 0;
height: .20rem;
white-space: nowrap;
overflow: hidden;
font-size: .14rem;
}
}
}
}
}
The html code is a simple table in a container div.
Gif about the no sticky headers when using flexbox:
Thanks for your time, help and answers in advance :)
----#Edit1 My question is about why display: flexbox and position: sticky does not work together and not about how to make fixed header table in pure css.