-
Notifications
You must be signed in to change notification settings - Fork 1
/
responsive.html
116 lines (94 loc) · 2.07 KB
/
responsive.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset='UTF-8'>
<title>Responsive Table</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
table {
width: 100%;
}
th { text-align: left }
table caption {
font-size : 2em;
background-color: #000050;
color : white;
margin-top : 0.75em;
margin-bottom : 0.4em;
}
@media screen and (max-width: 760px) {
table caption {
font-size: 1.5em;
}
/* Force table to not be like tables anymore */
thead, tbody, th, td, tr {
display: block;
}
thead tr { /* Hide headers */
display: none;
}
tr { border: 1px solid #ccc;
padding-bottom: 4px;}
td { /* Make td a row */
border: none;
border-bottom: 1px solid #eee;
position: relative;
padding-left: 50%;
}
td:before {
/* Make it like a table header */
position: absolute;
top: 6px;
left: 6px;
width: 45%;
padding-right: 5%;
white-space: nowrap;
}
td:nth-of-type(1):before { content: "Column one" ; }
td:nth-of-type(2):before { content: "Column two" ; }
td:nth-of-type(3):before { content: "Column three"; }
td:nth-of-type(4):before { content: "Column four" ; }
}
</style>
</head>
<body>
<table><caption>Table caption</caption>
<thead><tr>
<th>Column one </th>
<th>Column two </th>
<th>Column three</th>
<th>Column four </th>
</tr></thead><tbody>
<tr>
<td>foo</td>
<td>bar</td>
<td>baz</td>
<td>quxx</td>
</tr>
<tr>
<td>Hello world</td>
<td>Red</td>
<td>abc def</td>
<td>n/a</td>
</tr>
<tr>
<td>Goodbye, world</td>
<td>Blue</td>
<td>ghi jkl mno</td>
<td>sometimes</td>
</tr>
<tr>
<td>Underworld</td>
<td>Green</td>
<td>pqr stu</td>
<td>always</td>
</tr>
<tr>
<td>World cup</td>
<td>Yellow</td>
<td>vwx yz.</td>
<td>never</td>
</tr>
</tbody></table>
</body>
</html>