Skip to content

Instantly share code, notes, and snippets.

@jdlehman
Last active February 28, 2017 20:42
Show Gist options
  • Save jdlehman/de4eab2113204729ea50 to your computer and use it in GitHub Desktop.
Save jdlehman/de4eab2113204729ea50 to your computer and use it in GitHub Desktop.
Generated by SassMeister.com.
> 1%
last 2 versions
<div class="Table">
<div class="Table-row Table-header">
<div class="Table-row-item u-Flex-grow2">Long Header1</div>
<div class="Table-row-item">Header2</div>
<div class="Table-row-item">Header3</div>
<div class="Table-row-item">Header4</div>
<div class="Table-row-item u-Flex-grow3">Longer Header5</div>
<div class="Table-row-item">Header6</div>
<div class="Table-row-item">Header7</div>
</div>
<div class="Table-row">
<div class="Table-row-item u-Flex-grow2" 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 class="Table-row-item u-Flex-grow3" data-header="Header5">row1 col5</div>
<div class="Table-row-item" data-header="Header6">row1 col6</div>
<div class="Table-row-item" data-header="Header7">row1 col7</div>
</div>
<div class="Table-row">
<div class="Table-row-item u-Flex-grow2" 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 class="Table-row-item u-Flex-grow3" data-header="Header5">row2 col5</div>
<div class="Table-row-item" data-header="Header6">row2 col6</div>
<div class="Table-row-item" data-header="Header7">row2 col7</div>
</div>
<div class="Table-row">
<div class="Table-row-item u-Flex-grow2" 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 class="Table-row-item u-Flex-grow3" data-header="Header5">row3 col5</div>
<div class="Table-row-item" data-header="Header6">row3 col6</div>
<div class="Table-row-item" data-header="Header7">row3 col7</div>
</div>
<div class="Table-row">
<div class="Table-row-item u-Flex-grow2" data-header="Header1">row4 col1</div>
<div class="Table-row-item" data-header="Header2">row4 col2</div>
<div class="Table-row-item" data-header="Header3">row4 col3</div>
<div class="Table-row-item" data-header="Header4">row4 col4</div>
<div class="Table-row-item u-Flex-grow3" data-header="Header5">row4 col5</div>
<div class="Table-row-item" data-header="Header6">row4 col6</div>
<div class="Table-row-item" data-header="Header7">row4 col7</div>
</div>
</div>
// ----
// Sass (v3.4.21)
// Compass (v1.0.3)
// Breakpoint (v2.6.1)
// ----
@import "breakpoint";
.Table {
$light-color: #ffffff;
$dark-color: #f2f2f2;
$md: 500px;
display: flex;
flex-flow: column nowrap;
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) {
display: flex;
flex-flow: row nowrap;
&:nth-of-type(even) { background-color: $light-color; }
&:nth-of-type(odd) { background-color: $dark-color; }
}
// .Table-row-item
&-item {
display: flex;
flex-flow: row nowrap;
flex-grow: 1;
flex-basis: 0;
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; }
}
}
}
}
@for $i from 1 through 10 {
.u-Flex-grow#{$i} {
flex-grow: i;
}
}
.Table {
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
-webkit-flex-flow: column nowrap;
-ms-flex-flow: column nowrap;
flex-flow: column nowrap;
-webkit-box-pack: justify;
-webkit-justify-content: space-between;
-ms-flex-pack: justify;
justify-content: space-between;
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: -webkit-flex;
display: -ms-flexbox;
display: flex;
-webkit-flex-flow: row nowrap;
-ms-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: -webkit-flex;
display: -ms-flexbox;
display: flex;
-webkit-flex-flow: row nowrap;
-ms-flex-flow: row nowrap;
flex-flow: row nowrap;
-webkit-box-flex: 1;
-webkit-flex-grow: 1;
-ms-flex-positive: 1;
flex-grow: 1;
-webkit-flex-basis: 0;
-ms-flex-preferred-size: 0;
flex-basis: 0;
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;
}
}
.u-Flex-grow1 {
-webkit-box-flex: i;
-webkit-flex-grow: i;
-ms-flex-positive: i;
flex-grow: i;
}
.u-Flex-grow2 {
-webkit-box-flex: i;
-webkit-flex-grow: i;
-ms-flex-positive: i;
flex-grow: i;
}
.u-Flex-grow3 {
-webkit-box-flex: i;
-webkit-flex-grow: i;
-ms-flex-positive: i;
flex-grow: i;
}
.u-Flex-grow4 {
-webkit-box-flex: i;
-webkit-flex-grow: i;
-ms-flex-positive: i;
flex-grow: i;
}
.u-Flex-grow5 {
-webkit-box-flex: i;
-webkit-flex-grow: i;
-ms-flex-positive: i;
flex-grow: i;
}
.u-Flex-grow6 {
-webkit-box-flex: i;
-webkit-flex-grow: i;
-ms-flex-positive: i;
flex-grow: i;
}
.u-Flex-grow7 {
-webkit-box-flex: i;
-webkit-flex-grow: i;
-ms-flex-positive: i;
flex-grow: i;
}
.u-Flex-grow8 {
-webkit-box-flex: i;
-webkit-flex-grow: i;
-ms-flex-positive: i;
flex-grow: i;
}
.u-Flex-grow9 {
-webkit-box-flex: i;
-webkit-flex-grow: i;
-ms-flex-positive: i;
flex-grow: i;
}
.u-Flex-grow10 {
-webkit-box-flex: i;
-webkit-flex-grow: i;
-ms-flex-positive: i;
flex-grow: i;
}
<div class="Table">
<div class="Table-row Table-header">
<div class="Table-row-item u-Flex-grow2">Long Header1</div>
<div class="Table-row-item">Header2</div>
<div class="Table-row-item">Header3</div>
<div class="Table-row-item">Header4</div>
<div class="Table-row-item u-Flex-grow3">Longer Header5</div>
<div class="Table-row-item">Header6</div>
<div class="Table-row-item">Header7</div>
</div>
<div class="Table-row">
<div class="Table-row-item u-Flex-grow2" 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 class="Table-row-item u-Flex-grow3" data-header="Header5">row1 col5</div>
<div class="Table-row-item" data-header="Header6">row1 col6</div>
<div class="Table-row-item" data-header="Header7">row1 col7</div>
</div>
<div class="Table-row">
<div class="Table-row-item u-Flex-grow2" 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 class="Table-row-item u-Flex-grow3" data-header="Header5">row2 col5</div>
<div class="Table-row-item" data-header="Header6">row2 col6</div>
<div class="Table-row-item" data-header="Header7">row2 col7</div>
</div>
<div class="Table-row">
<div class="Table-row-item u-Flex-grow2" 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 class="Table-row-item u-Flex-grow3" data-header="Header5">row3 col5</div>
<div class="Table-row-item" data-header="Header6">row3 col6</div>
<div class="Table-row-item" data-header="Header7">row3 col7</div>
</div>
<div class="Table-row">
<div class="Table-row-item u-Flex-grow2" data-header="Header1">row4 col1</div>
<div class="Table-row-item" data-header="Header2">row4 col2</div>
<div class="Table-row-item" data-header="Header3">row4 col3</div>
<div class="Table-row-item" data-header="Header4">row4 col4</div>
<div class="Table-row-item u-Flex-grow3" data-header="Header5">row4 col5</div>
<div class="Table-row-item" data-header="Header6">row4 col6</div>
<div class="Table-row-item" data-header="Header7">row4 col7</div>
</div>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment