<link href='https://fonts.googleapis.com/css?family=Comfortaa:400,700' rel='stylesheet' type='text/css'>
<h1>Table Style</h1>
<h2>Scroll + layout</h2>
<section>
<div class="table-wrapper">
<table>
<thead>
<tr>
<th>Big heading1</th>
<th>Big heading2</th>
<th>Big heading3</th>
<th>Big heading4</th>
<th>Big heading5</th>
<th>Big heading6</th>
</tr>
</thead>
<tbody>
<tr>
<td>Content1</td>
<td>Content2</td>
<td>Content3</td>
<td>Content4</td>
<td>Content5</td>
<td>Content6</td>
</tr>
<tr>
<td>Content7</td>
<td>Content8</td>
<td>Content9</td>
<td>Content10</td>
<td>Content11</td>
<td>Content12</td>
</tr>
<tr>
<td>Content13</td>
<td>Content14</td>
<td>Content15</td>
<td>Content16</td>
<td>Content17</td>
<td>Content18</td>
</tr>
</tbody>
</table>
</div>
<h3>↓</h3>
<div class="table-wrapper sp">
<table>
<thead>
<tr>
<th>Big heading1</th>
<th>Big heading2</th>
<th>Big heading3</th>
<th>Big heading4</th>
<th>Big heading5</th>
<th>Big heading6</th>
</tr>
</thead>
<tbody>
<tr>
<td>Content1</td>
<td>Content2</td>
<td>Content3</td>
<td>Content4</td>
<td>Content5</td>
<td>Content6</td>
</tr>
<tr>
<td>Content7</td>
<td>Content8</td>
<td>Content9</td>
<td>Content10</td>
<td>Content11</td>
<td>Content12</td>
</tr>
<tr>
<td>Content13</td>
<td>Content14</td>
<td>Content15</td>
<td>Content16</td>
<td>Content17</td>
<td>Content18</td>
</tr>
</tbody>
</table>
</div>
</section>
body{
font-family: 'Comfortaa', cursive;
}
h1 {
text-align: center;
letter-spacing: 2px;
font-weight: 300;
font-size:40px;
margin-top: 80px;
}
h2{
text-align:center;
font-size:25px;
font-weight: 100;
margin-top: 20px;
}
h3{
text-align:center;
margin: 30px 0px;
font-size: 30px;
}
section{
width: 700px;
margin:50px auto;
p{
font-size:20px;
font-weight: bold;
margin-bottom: 15px;
}
}
table{
width:100%;
margin: auto;
tr{
width: 100%;
}
th,td{
box-sizing:border-box;
padding: 15px;
font-size:16px;
}
thead{
th{
background: #000;
color: #fff;
text-align: left;
}
}
tbody{
text-align: left;
th{
background: #eee;
}
}
}
.sp{
width: 320px;
margin:auto;
overflow: hidden;
table{
display: block;
}
thead{
float: left;
display: block;
overflow-x: scroll;
th{
display: block;
width: auto;
}
}
tbody{
display: block;
width: auto;
overflow-x: auto;
white-space: nowrap;
td{
display: block;
}
tr{
display: inline-block;
}
}
}
// .sp::-webkit-scrollbar{
// background: #fff;
// border-radius: 5px;
// height: 4px;
// border: 1px solid #000;
// }
// .sp::-webkit-scrollbar-thumb{
// background:#000;
// border-radius: 5px;
// }
@media only screen and (max-width:420px){
body{
width: 100%;
}
.table-wrapper{
width: 100%;
}
.sp{
width: 100%;
}
table{
width: 100%;
display: block;
}
thead{
float: left;
display: block;
overflow-x: scroll;
th{
display: block;
width: auto;
}
}
tbody{
display: block;
width: auto;
overflow-x: auto;
white-space: nowrap;
td{
display: block;
}
tr{
display: inline-block;
font-size:0px;
}
}
// .table-wrapper{
// width: 100%;
// overflow-x: scroll;
// }
// .table-wrapper::-webkit-scrollbar{
// background: #fff;
// border-radius: 5px;
// height: 4px;
// border: 1px solid #000;
// }
// .table-wrapper::-webkit-scrollbar-thumb{
// background:#000;
// border-radius: 5px;
// }
section{
box-sizing:border-box;
width: 100%;
padding: 0px 20px;
}
}
View Compiled
This Pen doesn't use any external CSS resources.