JSFiddle - React, Tailwind, and code Playground
HTML
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.2/css/bootstrap.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<h2>TableHeadFixer Fix Head and Left Column</h2>
<div id="parent">
<table id="fixTable" class="table table-striped">
<thead>
<tr style="background-color: lightgrey">
<th id="head-1">Head 1</th>
<th id="head-2">Head 2</th>
<th>
<button type="button" class="btn btn-danger btn-xs remove-reservation"><span class="glyphicon glyphicon-trash"></span></button>
</th>
<th>Mar</th>
<th>Abr</th>
<th>Maio</th>
<th>Total</th>
</tr>
<tr style="background-color: lightgrey">
<th style="width: 250px; background-color: lightgrey">
<div class="form-group">
<label>Input</label>
<input id="global-name" class="form-control" type="text" placeholder="baris1892"/>
</div>
</th>
<th>222 Jan</th>
<th>222 Fev</th>
<th>222 Mar</th>
<th>222 Abr</th>
<th>222 Maio</th>
<th>222 Total</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<button class="btn btn-primary">User 1</button>
</td>
<td>
<button type="button" class="btn-test btn btn-success btn-block">+</button>
</td>
<td>100.00</td>
<td>100.00</td>
<td>100.00</td>
<td>100.00</td>
<td>500.00</td>
</tr>
<tr>
<td>
<button class="btn btn-primary">User 2</button>
</td>
<td>
<button type="button" class="btn-test btn btn-success btn-block">+</button>
</td>
<td>110.00</td>
...
CSS
#parent {
height: 500px;
width: 1200px;
}
#fixTable {
width: 2000px !important;
}
.table {
border-collapse: unset;
}
JavaScript
(function ($) {
$.fn.tableHeadFixer = function (param) {
return this.each(function () {
table.call(this);
});
function table() {
/*
This function solver z-index problem in corner cell where fix row and column at the same time,
set corner cells z-index 1 more then other fixed cells
*/
function setCorner() {
var table = $(settings.table);
if (settings.head) {
if (settings.left > 0) {
var tr = table.find("thead tr");
tr.each(function (k, row) {
solverLeftColspan(row, function (cell) {
$(cell).css("z-index", settings['z-index'] + 1);
});
});
}
if (settings.right > 0) {
var tr = table.find("thead tr");
tr.each(function (k, row) {
solveRightColspan(row, function (cell) {
$(cell).css("z-index", settings['z-index'] + 1);
});
});
}
}
if (settings.foot) {
if (settings.left > 0) {
var tr = table.find("tfoot tr");
tr.each(function (k, row) {
solverLeftColspan(row, function (cell) {
$(cell).css("z-index", settings['z-index']);
});
});
}
if (settings.right > 0) {
var tr = table.find("tfoot tr");
tr.each(function (k, row) {
solveRightColspan(row, function (cell) {
$(cell).css("z-index",...