Last active
August 29, 2015 14:07
-
-
Save gotpop/92863f087692efe824ca to your computer and use it in GitHub Desktop.
Simple responsive tables
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
##Simple responsive tables | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="table-wrapper"> | |
<div> | |
<table border="0" class="pricing-table-a"> | |
<tbody> | |
<tr><th> </th><th>Medical</th><th>Cancellation</th><th>Winter Sports Equipment</th><th>Piste Closure</th><th>Price<sup>(1)</sup></th></tr> | |
<tr class="highlight"> | |
<td>Columbus Direct</td> | |
<td>£10 million</td> | |
<td>£3,000</td> | |
<td>£400</td> | |
<td>£300</td> | |
<td>£21.40</td> | |
</tr> | |
<tr> | |
<td>Direct Travel Insurance</td> | |
<td>£10 million</td> | |
<td>£3,000</td> | |
<td>£400</td> | |
<td>£300</td> | |
<td>£40.93</td> | |
</tr> | |
<tr> | |
<td>Post Office</td> | |
<td>£10 million</td> | |
<td>£5,000</td> | |
<td>£700</td> | |
<td>£300</td> | |
<td>£48.50</td> | |
</tr> | |
<tr> | |
<td>Ski Club of Great Britain</td> | |
<td>£5 million</td> | |
<td>£2,000</td> | |
<td>£650</td> | |
<td>£200</td> | |
<td>£50.77</td> | |
</tr> | |
</tbody> | |
</table> | |
</div> | |
</div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/////////////////////////////////////////////////////////////////////////////////////////////// | |
// These three tables will be A/B tested ... only one table can survive | |
/////////////////////////////////////////////////////////////////////////////////////////////// | |
/////////////////////////////////////////////////////////////////////////////////////////////// | |
// Table wrapper | |
/////////////////////////////////////////////////////////////////////////////////////////////// | |
.table-wrapper { | |
overflow: hidden; | |
position: relative; | |
&:after { | |
// Mobile shadow | |
content: ""; | |
position: absolute; | |
top: 0; | |
left: 100%; | |
width: 50px; | |
height: 100%; | |
border-radius: 10px 0 0 10px / 50% 0 0 50%; | |
box-shadow: -5px 0 10px rgba(0, 0, 0, .25); | |
} | |
& > div { | |
overflow-x: auto; | |
&::-webkit-scrollbar { | |
-webkit-appearance: none; | |
width: 14px; | |
height: 14px; | |
} | |
&::-webkit-scrollbar-thumb { | |
border-radius: 8px; | |
border: 3px solid #fff; | |
background-color: rgba(0, 0, 0, .3); | |
} | |
} | |
@include media($tablet) { | |
overflow: visible; | |
box-shadow: none; | |
&:after { | |
content: none; | |
} | |
} | |
} | |
/////////////////////////////////////////////////////////////////////////////////////////////// | |
// Pricing table base | |
/////////////////////////////////////////////////////////////////////////////////////////////// | |
.pricing-table { | |
margin: 10px 0 20px 0; | |
text-align: center; | |
width: 180%; | |
font-size: 12px; | |
overflow: hidden; | |
@include media($tablet) { | |
width: 100%; | |
font-size: 14px; | |
} | |
sup { | |
font-weight: normal; | |
padding: 3px; | |
} | |
th, td { | |
padding: 5px 5px; | |
} | |
th { | |
background: $col-blue; | |
color: $white-bright; | |
border: none; | |
padding: 5px 10px; | |
text-align: center; | |
border-radius: 12px 12px 0 0; | |
border-left: 1px solid rgba( 255, 255, 255, .2); | |
&:first-child { | |
background: transparent; | |
} | |
} | |
td:first-child { | |
font-weight: bold; | |
text-align: left; | |
} | |
tr { | |
transition: .5 opacity ease; | |
} | |
tr:hover { | |
opacity: .8; | |
transition: .5 opacity ease; | |
} | |
// Columbus row | |
tr:nth-child(2) { | |
font-size: 1.3em; | |
font-weight: bold; | |
color: rgba(white, 1); | |
td { | |
background: lighten( $col-blue-accent, 12% ) ; | |
} | |
} | |
} | |
/////////////////////////////////////////////////////////////////////////////////////////////// | |
// Pricing table a | |
/////////////////////////////////////////////////////////////////////////////////////////////// | |
.pricing-table.c { | |
th { | |
color: rgba($col-blue-accent, .97); | |
text-transform: uppercase; | |
} | |
tr:nth-child(odd) td { | |
background: rgba(#e6e7e9, 1); | |
} | |
tr:nth-child(even) td { | |
background: rgba(#d0d1d5, 1); | |
} | |
td { | |
border-right: 1px solid rgba(white, .4); | |
border-top: 1px solid rgba(white, .7); | |
color: $col-blue; | |
} | |
td:first-child { | |
text-transform: uppercase; | |
} | |
tr:nth-child(2) td { | |
background: lighten( $col-blue-accent, 12% ); | |
color: rgba(white, .87); | |
font-size: .8em; | |
&:first-child { | |
background: $col-blue-accent; | |
} | |
} | |
tr:nth-child(2) td:first-child { | |
position: relative; | |
&:after { | |
content: ''; | |
@include triangle(30px, $col-blue-accent, right); | |
display: block; | |
position: absolute; | |
right: -28px; | |
top: 2px; | |
@include media($tablet) { | |
top: 3px; | |
} | |
} | |
} | |
} | |
/////////////////////////////////////////////////////////////////////////////////////////////// | |
// Pricing table b | |
/////////////////////////////////////////////////////////////////////////////////////////////// | |
.pricing-table.b { | |
th { | |
text-transform: uppercase; | |
color: $col-blue-accent; | |
} | |
tr:nth-child(even) td { | |
background: rgba(#e6e7e9, 1); | |
} | |
tr:nth-child(odd) td { | |
background: rgba(#d0d1d5, 1); | |
} | |
td { | |
border-right: 1px solid rgba(white, .2); | |
border-top: 1px solid rgba(white, .2); | |
color: $col-blue; | |
} | |
td:first-child { | |
text-transform: uppercase; | |
} | |
tr:nth-child(2) td { | |
background: lighten( $col-blue-accent, 12% ); | |
color: rgba(white, .87); | |
font-size: .8em; | |
&:first-child { | |
background: $col-blue-accent; | |
} | |
} | |
} | |
/////////////////////////////////////////////////////////////////////////////////////////////// | |
// Pricing table c | |
/////////////////////////////////////////////////////////////////////////////////////////////// | |
.pricing-table.a { | |
color: rgba(white, .87); | |
td { | |
border-right: 1px solid rgba(white, .2); | |
} | |
tr:nth-child(odd) td { | |
background: $col-blue; | |
} | |
tr:nth-child(even) td { | |
background: desaturate( lighten( $col-blue, 10% ), 40% ) ; | |
font-weight: bold; | |
} | |
// Override first column of each row | |
tr td:first-child { | |
background: transparent; | |
color: $col-blue; | |
} | |
// Columbus row | |
tr:nth-child(2) td { | |
background: lighten( $col-blue-accent, 12% ) ; | |
&:first-child { | |
color: rgba(white, .87); | |
background: $col-blue-accent; | |
} | |
} | |
} | |
// Columbus row | |
.pricing-table.a tr:nth-child(2) { | |
td:first-child { | |
border-radius: 5px; | |
margin: 2px 10px 2px 0; | |
padding: 5px 26px; | |
text-align: center; | |
position: relative; | |
display: block; | |
bottom: 1px; | |
&:after { | |
content: ''; | |
@include triangle(30px, $col-blue-accent, right); | |
display: block; | |
position: absolute; | |
right: -28px; | |
top: 2px; | |
@include media($tablet) { | |
top: 14px; | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment