html - Lock a column with CSS -


edit: tried solution recommended in topic post may have been duplicate of. copy , pasted solution jsfiddle.net/djqpf/7/ john.nichel.net/test2.html (i don't have enough rep post 2 links can't give http) , doesn't scroll @ all.

i'm looking lock 1 or 2 columns of data in table or div using css, meaning other columns scroll locked ones not.

i've tried few jquery plugins , many of css/div examples i've found but, whatever reason, can't make unlocked columns start after locked one. i've tried positions absolute, fixed, relative, etc., can't seem these examples work. how can achieve this?

the code below @ http://john.nichel.net/test.html can see how locked column displayed on other columns. i'm going keep working on this, code on site different i've posted below.

.table {    display: table;  }    .header {    display: table-header-group;    font-weight: bold;  }    .rowgroup {    display: table-row-group;  }    .row {    display: table-row;  }    .cell {    display: table-cell;    white-space: nowrap;  }    .cell_locked {    position: absolute;    display: table-cell;    white-space: nowrap;  }
<center>    <div style="overflow-x:auto;width:770px;overflow:scroll;">      <div class="table">        <div class="header">          <div class="cell_locked">test lock</div>          <div class="cell">unlocked cell 1</div>          <div class="cell">unlocked cell 2</div>          <div class="cell">unlocked cell 3</div>          <div class="cell">unlocked cell 4</div>          <div class="cell">unlocked cell 5</div>          <div class="cell">unlocked cell 6</div>          <div class="cell">unlocked cell 7</div>          <div class="cell">unlocked cell 8</div>          <div class="cell">unlocked cell 9</div>          <div class="cell">unlocked cell 10</div>        </div>      </div>  </center>

here simple sollution this. can make 2 tables instead of one. first table has on column locked cells, second 1 fixed first 1 , containes scrollables rows. thing should position 2 tables thay 1 element. , here reasons don't understand have pack both tables div , give artibite display: flex, don't understand, mean value of atribute. here code:

<!--container both tables--> <div class="container"> <!--first table -locked-->     <div class="table">         <div class="rowgroup">             <div class="cell_locked">test lock</div>         </div>         <div class="rowgroup">             <div class="cell_locked">test lock</div>         </div>     </div>  <!--second table -scrollable -->     <div class="table" style="overflow-x:auto;width:770px;overflow:scroll;">         <div class="rowgroup">                 <div class="cell">unlocked cell 1</div>                 <div class="cell">unlocked cell 2</div>                 <div class="cell">unlocked cell 3</div>                 <div class="cell">unlocked cell 4</div>                 <div class="cell">unlocked cell 5</div>                 <div class="cell">unlocked cell 6</div>                 <div class="cell">unlocked cell 7</div>                 <div class="cell">unlocked cell 8</div>                 <div class="cell">unlocked cell 9</div>                 <div class="cell">unlocked cell 10</div>         </div>         <div class="header">                 <div class="cell">unlocked cell 1</div>                 <div class="cell">unlocked cell 2</div>                 <div class="cell">unlocked cell 3</div>                 <div class="cell">unlocked cell 4</div>                 <div class="cell">unlocked cell 5</div>                 <div class="cell">unlocked cell 6</div>                 <div class="cell">unlocked cell 7</div>                 <div class="cell">unlocked cell 8</div>                 <div class="cell">unlocked cell 9</div>                 <div class="cell">unlocked cell 10</div>         </div>     </div> </div> 

and in styles:

.container {     display: flex; } 

now have scrolable elements in 1 scrollable div there 1 scrollbar.


Comments

Popular posts from this blog

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

python Tkinter Capturing keyboard events save as one single string -

sql server - Why does Linq-to-SQL add unnecessary COUNT()? -