Таблица адаптивной загрузки с фиксированными заголовками для всех размеров устройств? - PullRequest
3 голосов
/ 15 мая 2019

У меня в настоящее время есть эта таблица Bootstrap, и проблема, с которой я сталкиваюсь, заключается в том, что липкие заголовки не работают без удаления класса Bootabletrap .table-response. Возможно ли это без использования JS?

.table-responsive {
  display: block;
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.table-fixed {
  width: 100%;
}


/* This will work on every browser but Chrome Browser */

.table-fixed thead {
  position: sticky;
  position: -webkit-sticky;
  top: 0;
  z-index: 999;
  background-color: #FFF;
}


/*This will work on every browser*/

.table-fixed thead th {
  position: sticky;
  position: -webkit-sticky;
  top: 0;
  background-color: #FFF;
}
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" rel="stylesheet" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

<div class="table-responsive">
  <table class="table table-striped table-fixed">
    <thead>
      <tr>
        <th>Test</th>
        <th>Test</th>
      </tr>
    </thead>
  </table>
</div>
...