- const ITEMS_COUNT = 95
- const DATA_COUNT = 10
.card
.table-title
h2 CSS ONLY TABLE
.button-container
span These buttons aren't working >
button.danger Delete Selected
button.primary Add New Data
.table-concept
- let counter = 1
- let itemsCount = Math.ceil(ITEMS_COUNT / DATA_COUNT)
- for (let i = 0; i < itemsCount; i++)
- let currentPage = (i * DATA_COUNT)
- let dataCount = DATA_COUNT
- let dataDisplay = ITEMS_COUNT - ((i + 1) * DATA_COUNT)
- if (dataDisplay < 0) {
- dataCount = Math.abs(dataDisplay)
- }
input(
type="radio"
name="table_radio"
id="table_radio_" + i
checked=i == 0
).table-radio
.table-display
| Showing #{currentPage + 1} to #{currentPage + dataCount}
| of #{ITEMS_COUNT} items
table
thead
tr
th
th No
th FIRST HEADER
th SECOND HEADER
th THIRD HEADER
th FOURTH HEADER
th FIFTH HEADER
tbody
- for (let j = 0; j < dataCount; j++)
tr
td
input(type="checkbox")
td #{counter}
td This is Item number 1-#{counter}
td This is Item number 2-#{counter}
td This is Item number 3-#{counter}
td This is Item number 4-#{counter}
td This is Item number 5-#{counter}
- counter++
.pagination
label(
for="table_radio_" + (i - 1)
class=(i == 0) ? "disabled" : ""
) « Previous
- for (let j = 0; j < itemsCount; j++)
label(
for="table_radio_" + j
id="table_pager_" + j
class=(i == j) ? "active" : ""
) #{j + 1}
label(
for="table_radio_" + (i + 1)
class=(i == itemsCount - 1) ? "disabled" : ""
) Next »
View Compiled
$card-max-width: 600px;
$table-concept-max-height: 420px;
$table-background-color: #ffffff;
$table-hover-background-color: darken($table-background-color, 8%);
$table-even-background-color: darken($table-background-color, 4%);
$table-header-color: #ffffff;
$table-header-background-color: #2f2f2f;
$pagination-background-color: #6f6f6f;
$pagination-label-color: #ffffff;
$pagination-label-background-color: $pagination-background-color;
$pagination-label-active-color: #ffffff;
$pagination-label-active-background-color:
darken($pagination-background-color, 15%);
$pagination-label-disabled-color: #ffffff;
$pagination-label-disabled-background-color:
lighten($pagination-background-color, 15%);
$table-title-color: #ffffff;
$table-title-background-color: #2f2f2f;
@import url("https://fonts.googleapis.com/css?family=Open+Sans:400,400i,700");
@mixin button($background-color) {
background-color: $background-color;
&:hover {
background-color: lighten($background-color, 10%);
}
&:active {
background-color: darken($background-color, 10%);
}
}
body {
font-family: "Open Sans", sans-serif;
background-color: #c0c0c0;
width: 100vw;
height: 100vh;
display: flex;
align-items: center;
justify-content: center;
overflow: hidden;
}
.card {
background-color: #ffffff;
width: 100%;
max-width: $card-max-width;
box-shadow: 0 15px 35px rgba(#000000, 0.5);
}
.table-concept {
width: 100%;
height: 100%;
max-height: $table-concept-max-height;
overflow: auto;
position: relative;
.table-radio {
display: none;
&:checked + .table-display,
&:checked + .table-display + table {
display: block;
}
&:checked + .table-display + table + .pagination {
display: flex;
& > label.active {
color: $pagination-label-active-color;
background-color: $pagination-label-active-background-color;
cursor: default;
}
& > label.disabled {
color: $pagination-label-disabled-color;
background-color: $pagination-label-disabled-background-color;
cursor: default;
}
}
}
.table-display {
background-color: #e2e2e2;
text-align: right;
padding: 10px;
display: none;
position: sticky;
left: 0;
}
table {
background-color: $table-background-color;
font-size: 16px;
border-collapse: collapse;
display: none;
tr {
&:last-child {
td {
border-bottom: 0;
}
}
th,
td {
text-align: left;
padding: 15px;
box-sizing: border-box;
}
th {
color: $table-header-color;
background-color: $table-header-background-color;
border-bottom: solid 2px #d8d8d8;
position: sticky;
top: 0;
}
td {
border: solid 1px #d8d8d8;
border-left: 0;
border-right: 0;
white-space: nowrap;
}
}
tbody tr {
transition: background-color 150ms ease-out;
&:nth-child(2n) {
background-color: $table-even-background-color;
}
&:hover {
background-color: $table-hover-background-color;
}
}
}
.pagination {
background-color: $pagination-background-color;
width: 100%;
display: none;
position: sticky;
bottom: 0;
left: 0;
& > label {
@include button($pagination-label-background-color);
color: $pagination-label-color;
padding: 10px;
cursor: pointer;
}
}
}
.table-title {
color: $table-title-color;
background-color: $table-title-background-color;
padding: 15px;
h2 {
margin: 0;
padding: 0;
}
}
.button-container {
width: 100%;
box-sizing: border-box;
display: flex;
justify-content: flex-end;
span {
color: #8f8f8f;
text-align: right;
min-height: 100%;
display: flex;
align-items: center;
justify-content: center;
margin-left: 10px;
margin-right: 10px;
}
button {
font-family: inherit;
font-size: inherit;
font-weight: bold;
color: #ffffff;
padding: 10px;
border: 0;
margin: 0;
outline: 0;
border-radius: 0;
transition: background-color 225ms ease-out;
&.primary {
$background-color: #147eff;
background-color: $background-color;
&:hover {
background-color: lighten($background-color, 10%);
}
&:active {
background-color: darken($background-color, 10%);
}
}
&.primary {
@include button(#147eff);
}
&.danger {
@include button(#d11800);
}
}
}
View Compiled
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.