css 设置冻结表格头,纯CSS冻结表头

css

/* Colors */

/* Bidirectional Table */

div.frozen-table {

width: 100%;

min-height: 150px;

overflow: scroll;

margin: 0 auto;

/* Remove the below 3 properties on your Website (Test-Purpose) */

width: 800px;

height: 400px;

resize: both;

}

div.frozen-table table {

min-width: 100%;

min-height: 100%;

border-collapse: collapse;

}

div.frozen-table table th {

height: 100%;

border: 0px none transparent;

padding: 0;

}

div.frozen-table table th span {

display: block;

padding: 20px;

border-right: 1px solid #2d5aff;

}

div.frozen-table table thead tr th {

background: #2d5aff;

color: #ffffff;

position: relative;

z-index: 0;

}

div.frozen-table table thead tr:first-child th span {

border: 0px none transparent;

}

div.frozen-table table thead tr:first-child th:first-child {

background: #000000;

}

div.frozen-table table tbody th {

background: #ffffff;

}

div.frozen-table table tbody th:only-child {

z-index: -1;

}

div.frozen-table table tbody th:only-child span {

border: 0px none transparent;

border-top: 1px solid #2d5aff;

border-bottom: 1px solid #2d5aff;

}

div.frozen-table table tbody td {

background-color: #ffffff;

padding: 20px;

}

div.frozen-table[data-table="top"] thead th, div.frozen-table[data-table="both"] thead th {

position: -webkit-sticky;

position: sticky;

top: 0;

}

div.frozen-table[data-table="left"] tbody th, div.frozen-table[data-table="both"] tbody th {

position: -webkit-sticky;

position: sticky;

left: 0;

z-index: 1;

}

div.frozen-table[data-table="left"] thead th:first-child, div.frozen-table[data-table="both"] thead th:first-child {

position: -webkit-sticky;

position: sticky;

left: 0;

z-index: 2;

}

/* Some CSS to prettyfy the screen */

body {

text-align: center;

font-family: Arial, sans-serif;

margin: 0;

min-height: 100vh;

position: relative;

z-index: 1;

overflow: hidden;

overflow-y: auto;

background: linear-gradient(180deg, #ffc171 0%, #ff752d 100%);

background-repeat: no-repeat;

}

body:after {

content: " ";

display: block;

width: 100%;

height: 100%;

position: absolute;

left: 0;

top: 0;

z-index: -1;

opacity: .8;

background-image: url('data:image/svg+xml,%3Csvg xmlns="http://www.w3.org/2000/svg" width="28" height="49" viewBox="0 0 28 49"%3E%3Cg fill-rule="evenodd"%3E%3Cg id="hexagons" fill="%239C92AC" fill-opacity="0.4" fill-rule="nonzero"%3E%3Cpath d="M13.99 9.25l13 7.5v15l-13 7.5L1 31.75v-15l12.99-7.5zM3 17.9v12.7l10.99 6.34 11-6.35V17.9l-11-6.34L3 17.9zM0 15l12.98-7.5V0h-2v6.35L0 12.69v2.3zm0 18.5L12.98 41v8h-2v-6.85L0 35.81v-2.3zM15 0v7.5L27.99 15H28v-2.31h-.01L17 6.35V0h-2zm0 49v-8l12.99-7.5H28v2.31h-.01L17 42.15V49h-2z"/%3E%3C/g%3E%3C/g%3E%3C/svg%3E');

}

body #main-wrapper {

padding: 40px 0;

}

body .contrast-bg {

padding: 15px;

background-color: rgba(255, 255, 255, 0.6);

margin-bottom: 60px;

}

body .contrast-bg p {

margin-top: 0;

}

你可能感兴趣的:(css,设置冻结表格头)