Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save lahiponeja/59f206cecb1f385d1553fe5c345e1dc2 to your computer and use it in GitHub Desktop.
Save lahiponeja/59f206cecb1f385d1553fe5c345e1dc2 to your computer and use it in GitHub Desktop.
Generated by SassMeister.com.
<div class="Table">
<div class="Table-row Table-header">
<div class="Table-row-item">Header1</div>
<div class="Table-row-item">Header2</div>
<div class="Table-row-item">Header3</div>
<div class="Table-row-item">Header4</div>
</div>
<div class="Table-row">
<div class="Table-row-item" data-header="Header1">row1 col1</div>
<div class="Table-row-item" data-header="Header2">row1 col2</div>
<div class="Table-row-item" data-header="Header3">row1 col3</div>
<div class="Table-row-item" data-header="Header4">row1 col4</div>
</div>
<div class="Table-row">
<div class="Table-row-item" data-header="Header1">row2 col1</div>
<div class="Table-row-item" data-header="Header2">row2 col2</div>
<div class="Table-row-item" data-header="Header3">row2 col3</div>
<div class="Table-row-item" data-header="Header4">row2 col4</div>
</div>
<div class="Table-row">
<div class="Table-row-item" data-header="Header1">row3 col1</div>
<div class="Table-row-item" data-header="Header2">row3 col2</div>
<div class="Table-row-item" data-header="Header3">row3 col3</div>
<div class="Table-row-item" data-header="Header4">row3 col4</div>
</div>
</div>
// ----
// Sass (v3.4.4)
// Compass (v1.0.1)
// Bourbon (v4.0.2)
// Breakpoint (v2.5.0)
// ----
@import "bourbon/bourbon";
@import "breakpoint";
.Table {
$light-color: #ffffff;
$dark-color: #f2f2f2;
$md: 500px;
@include display(flex);
@include flex-flow(column nowrap);
@include justify-content(space-between);
border: 1px solid $dark-color;
font-size: 1rem;
margin: 0.5rem;
line-height: 1.5;
// .Table-header
&-header {
display: none;
@include breakpoint($md) {
font-weight: 700;
background-color: $dark-color;
}
}
// .Table-row
&-row {
width: 100%;
&:nth-of-type(even) { background-color: $dark-color; }
&:nth-of-type(odd) { background-color: $light-color; }
@include breakpoint($md) {
@include display(flex);
@include flex-flow(row nowrap);
&:nth-of-type(even) { background-color: $light-color; }
&:nth-of-type(odd) { background-color: $dark-color; }
}
// .Table-row-item
&-item {
@include display(flex);
@include flex-flow(row nowrap);
@include flex-grow(1);
@include flex-basis(0);
@include word-wrap;
padding: 0.5em;
word-break: break-word;
&:before {
content: attr(data-header);
width: 30%;
font-weight: 700;
}
@include breakpoint($md) {
border: 1px solid $light-color;
padding: 0.5em;
&:before { content: none; }
}
}
}
}
.Table {
display: -webkit-box;
display: -moz-box;
display: box;
display: -webkit-flex;
display: -moz-flex;
display: -ms-flexbox;
display: flex;
-webkit-flex-flow: column nowrap;
-moz-flex-flow: column nowrap;
flex-flow: column nowrap;
-webkit-box-pack: justify;
-moz-box-pack: justify;
box-pack: justify;
-webkit-justify-content: space-between;
-moz-justify-content: space-between;
-ms-justify-content: space-between;
-o-justify-content: space-between;
justify-content: space-between;
-ms-flex-pack: justify;
border: 1px solid #f2f2f2;
font-size: 1rem;
margin: 0.5rem;
line-height: 1.5;
}
.Table-header {
display: none;
}
@media (min-width: 500px) {
.Table-header {
font-weight: 700;
background-color: #f2f2f2;
}
}
.Table-row {
width: 100%;
}
.Table-row:nth-of-type(even) {
background-color: #f2f2f2;
}
.Table-row:nth-of-type(odd) {
background-color: #ffffff;
}
@media (min-width: 500px) {
.Table-row {
display: -webkit-box;
display: -moz-box;
display: box;
display: -webkit-flex;
display: -moz-flex;
display: -ms-flexbox;
display: flex;
-webkit-flex-flow: row nowrap;
-moz-flex-flow: row nowrap;
flex-flow: row nowrap;
}
.Table-row:nth-of-type(even) {
background-color: #ffffff;
}
.Table-row:nth-of-type(odd) {
background-color: #f2f2f2;
}
}
.Table-row-item {
display: -webkit-box;
display: -moz-box;
display: box;
display: -webkit-flex;
display: -moz-flex;
display: -ms-flexbox;
display: flex;
-webkit-flex-flow: row nowrap;
-moz-flex-flow: row nowrap;
flex-flow: row nowrap;
-webkit-flex-grow: 1;
-moz-flex-grow: 1;
flex-grow: 1;
-ms-flex-positive: 1;
-webkit-flex-basis: 0;
-moz-flex-basis: 0;
flex-basis: 0;
-ms-flex-preferred-size: 0;
word-wrap: break-word;
overflow-wrap: break-word;
word-break: break-all;
padding: 0.5em;
word-break: break-word;
}
.Table-row-item:before {
content: attr(data-header);
width: 30%;
font-weight: 700;
}
@media (min-width: 500px) {
.Table-row-item {
border: 1px solid #ffffff;
padding: 0.5em;
}
.Table-row-item:before {
content: none;
}
}
<div class="Table">
<div class="Table-row Table-header">
<div class="Table-row-item">Header1</div>
<div class="Table-row-item">Header2</div>
<div class="Table-row-item">Header3</div>
<div class="Table-row-item">Header4</div>
</div>
<div class="Table-row">
<div class="Table-row-item" data-header="Header1">row1 col1</div>
<div class="Table-row-item" data-header="Header2">row1 col2</div>
<div class="Table-row-item" data-header="Header3">row1 col3</div>
<div class="Table-row-item" data-header="Header4">row1 col4</div>
</div>
<div class="Table-row">
<div class="Table-row-item" data-header="Header1">row2 col1</div>
<div class="Table-row-item" data-header="Header2">row2 col2</div>
<div class="Table-row-item" data-header="Header3">row2 col3</div>
<div class="Table-row-item" data-header="Header4">row2 col4</div>
</div>
<div class="Table-row">
<div class="Table-row-item" data-header="Header1">row3 col1</div>
<div class="Table-row-item" data-header="Header2">row3 col2</div>
<div class="Table-row-item" data-header="Header3">row3 col3</div>
<div class="Table-row-item" data-header="Header4">row3 col4</div>
</div>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment