forked from wesbos/hot-tips
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflexible-text.html
90 lines (75 loc) · 1.69 KB
/
flexible-text.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Container Queries</title>
<link rel="stylesheet" href="../base.css">
</head>
<body>
<article class="container">
<h2>Container Queries</h2>
</article>
<article class="container" >
<h2 class="fit" style="--letters:12;">Are awesome!</h2>
</article>
<article class="container">
<h2 class="fit" style="--letters:25;">Resize me you silly goose</h2>
</article>
<article class="container">
<h2>in Chrome, Safari, iOS, Edge</h2>
</article>
<article class="container">
<h2>in Firefox Feb 14th 💕</h2>
</article>
<style>
.container {
container: article / inline-size;
}
h2 {
font-size: 7cqw;
}
@container article (width < 150px) {
h2 {
color: #ffc600;
}
}
h2.fit {
font-family: 'Operator Mono', 'monospace';
/* 12 letters */
--minFontSize: 10px;
font-size: max(
var(--minFontSize),
calc(calc(100 / var(--letters)) * 1.5cqw)
);
}
</style>
<style>
body {
background: url('grad.png');
height: 100vh;
display: flex;
flex-direction: row;
flex-wrap: wrap;
display: grid;
grid-template-columns: 1fr;
align-content: center;
align-items: center;
}
.container {
background: white;
padding: 10px;
border-radius: 20px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);
overflow: hidden;
resize: horizontal;
margin: 1em auto;
width: 50%;
}
h2 {
margin: 0;
text-align: center;
}
</style>
</body>
</html>