0

I have created a flexbox based table, which is stripped to the basics the example below.

<!-- display: flex;flex-flow: column nowrap; flex:1 1 auto; --> 
<div class="ovdTable"> 
  <!-- display: flex; flex-flow: row nowrap; flex: 1 1 auto; -->
  <div class="ovdTable__table">  
    <!-- flex:1 1 auto; -->
    <div class="ovdTable__column">   
      <!-- display:flex; flex:none; -->                    
      <div class="ovdTable__cell ovdTable__cell--header"> 
      <!-- 1-n -->
      <div class="ovdTable__cell">                 
    </div>
  </div>
</div>

CSS class ovt_Table__cell--header adds the following style properties to the first cell in a column.

position: sticky;
position: -webkit-sticky;
top:0;

As expected i have search for similar stackoverflow articles and tried the solutions found there.

I have a CodePen example here.

Maybe I am totally wrong, but could i have made an error in the overflow settings?

TylerH
  • 20,799
  • 66
  • 75
  • 101
pcvnes
  • 927
  • 2
  • 15
  • 41
  • Please keep solutions to the answer section. I'm not sure why you deleted the answer you wrote and included it in the question, but questions should not contain solutions. I would recommend undeleting your answer and marking it as the accepted answer. – TylerH Apr 01 '21 at 18:44

1 Answers1

1

I was able to resolve it by adding an extra div inside the div with class "ovdTable" containing the header cells and making this div 'sticky' with an elevated z-index.

<!-- display: flex;flex-flow: column nowrap; flex:1 1 auto; --> 
<div class="ovdTable"> 
    <!-- display: flex; flex-flow: row nowrap; flex: 1 1 auto; -->
    <!-- position: sticky; top:0px; z-index:2; --> 
    <div class="ovdTable__tableHeader"> 
      <!-- 1-n -->
      <div class="ovdTable__tableHeader--column">Column 1</div>
    </div>
    <!-- display: flex; flex-flow: row nowrap; flex: 1 1 auto; -->
    <div class="ovdTable__tableContent">  
        <!-- flex:1 1 auto; -->
        <div class="ovdTable__column">   
            <!-- 1-n -->
            <div class="ovdTable__cell">                 
        </div>
    </div>
</div>

I have updated the codepen to match the solution.

pcvnes
  • 927
  • 2
  • 15
  • 41