-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
127 lines (101 loc) · 2.34 KB
/
index.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
117
118
119
120
121
122
123
124
125
126
127
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<style>
* {
box-sizing: border-box;
}
body {
padding: 120px 0 0 0;
font-family: Arial, sans-serif;
word-break: break-word;
}
.Component {
font-size: 20px;
padding: 1em;
max-width: 30em;
border: solid 2px #ccc;
margin: 0 auto;
color: #666;
border-radius: 1em 0 1em 1em;
position: relative;
overflow: hidden;
}
.Component:after {
content: '';
display: block;
border-radius: 50% 0 50% 50%;
width: 2em;
height: 2em;
position: absolute;
top: .2em;
right: .2em;
background: #bbb;
}
.Component h2 {
font-size: 2em;
margin: 0 0 .4em;
}
.Component img {
max-width: 100%;
height: auto;
border: solid .3em #ccc;
float: left;
margin: 0 1em 1em 0;
}
.Component p {
font-size: 1em;
margin: 1em 0 0 0;
text-align: left;
}
input[type="range"] {
margin: 20px auto;
display: block;
}
.admin {
position: fixed;
background: #eee;
top: 0;
left: 0;
right: 0;
z-index: 999;
}
p {
text-align: center;
}
@media screen and (max-width: 700px) {
.Component {
font-size: 14px;
}
}
@media screen and (max-width: 400px) {
.Component {
font-size: 10px;
width: auto;
}
}
</style>
</head>
<body>
<div class="admin">
<input type="range" min="10" max="35" step="1" value="20" id="slider">
<p>Base unit is: <output id="op">20px</output><p>
</div>
<div class="Component" id="mod">
<h2>Component Title</h2>
<img src="http://placekitten.com/250/250" alt="Kitten">
<p><strong>Use the range slider above</strong>.<br>The size of each element inside this module is controlled by a single unit: The <code>font-size</code>, which acts as a "root" for our em units, making everything inside the component proportionally resizable.</p>
</div>
<p class="p">Demo by Louis Lazaris. <a href="http://codepen.io/SitePoint/pen/BtJFn">CodePen</a> <a href="http://www.sitepoint.com/power-em-units-css/">See article</a> and <a href="https://medium.com/front-end-development/8f433689736f">original inspiration</a>.</p>
<script>
var slider = document.getElementById('slider'),
mod = document.getElementById('mod'),
op = document.getElementById('op');
slider.onchange = function () {
mod.style.fontSize = this.value + 'px';
op.innerHTML = this.value + 'px';
}
</script>
</body>
</html>