I have a div where I have a dropdown and then on the bottom there's a table. I am using ngx-infinite-scrolling, and when I scroll i want the div and the header of the table to remain fixed as more data is added and scrolled down.
This is a jsfiddle JSFiddle
Html code:
<div class="topTable row ">
<div class="col-md-4 col-lg-3 col-sm-4 col-6">
<form class="form-inline">
<div class="form-group" style="width:100%;max-width:200px;">
<div class="input-group" style="width:100%">
<select class="form-control" >
<option >All</option>
<option >Option1</option>
<option >Option1</option>
<option >Option1</option>
</select>
</div>
</div>
<div class="container-fluid">
<div class="col-md-12">
<div class="col-md-12 tableDiv" >
<div class="constrained" >
<table class="table table-striped col-md-12 table-condensed cf" >
<thead class="table-bordered cf">
<tr>
<th>Column1</th>
<th>Column2</th>
<th>Column3</th>
<th>Column4</th>
<th>Column5</th>
<th>Column6</th>
</tr>
</thead>
<tbody >
<tr>
<td > asdf</td>
<td >asdfa</td>
<td >fsdf</td>
<td>sdfsfd</td>
<td>sdfs</td>
<td>fsdfsdf</td>
</tr>
<tr>
<td > asdf</td>
<td >asdfa</td>
<td >fsdf</td>
<td>sdfsfd</td>
<td>sdfs</td>
<td>fsdfsdf</td>
</tr>
<tr>
<td > asdf</td>
<td >asdfa</td>
<td >fsdf</td>
<td>sdfsfd</td>
<td>sdfs</td>
<td>fsdfsdf</td>
</tr>
<tr>
<td > asdf</td>
<td >asdfa</td>
<td >fsdf</td>
<td>sdfsfd</td>
<td>sdfs</td>
<td>fsdfsdf</td>
</tr>
<tr>
<td > asdf</td>
<td >asdfa</td>
<td >fsdf</td>
<td>sdfsfd</td>
<td>sdfs</td>
<td>fsdfsdf</td>
</tr>
<tr>
<td > asdf</td>
<td >asdfa</td>
<td >fsdf</td>
<td>sdfsfd</td>
<td>sdfs</td>
<td>fsdfsdf</td>
</tr>
</tbody>
</table>
</div>
<div>
</div>
</div>
</div>
</div>
CSS:
.topTable{
height:70px;
background:red;
margin-top:-20px;
margin-bottom:20px;
display: flex;
padding-left: 32px;
border:1px solid rgba(0,0,0,.1)
}
.tableDiv{
margin-top:50px
}
I tried putting position:static on the div, but then on scroll down, table would go on top of it. How to also make table static and its header fixed ? Any help is appreciated