/
index.html
92 lines (82 loc) · 2.5 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
<!DOCTYPE html>
<html>
<head>
<title>Proportional Font-sizing test</title>
<link rel="stylesheet" type="text/css" href="../../tests.css" />
<style>
iframe#reader {
border: 1px solid #F0F;
margin: 20px 0;
overflow: auto;
}
</style>
<script src="test.js"></script>
</head>
<body class="narrow">
<a href="../../index.html" class="backToGuide">← Back to Guide</a>
<h1>Proportional Font-sizing test</h1>
<p>
Select a font-scale:
<select id="sizeSelect">
<option value="">—</option>
<option value="0.1">10%</option>
<option value="0.5">50%</option>
<option value="0.8">80%</option>
<option value="1.0">100%</option>
<option value="1.1">110%</option>
<option value="1.3">130%</option>
<option value="1.6">160%</option>
<option value="2.0">200%</option>
<option value="2.5">250%</option>
<option value="4.0">400%</option>
<option value="8.0">800%</option>
</select>
</p>
<iframe
id="reader"
src="content.html"
width="330"
height="400"
frameborder="0"
></iframe>
<!--
src="../../showcase/02-dickens/components/2.html"
-->
<hr />
<p>
Proportional font-sizing is tricky for a few reasons.
Firstly, we need to scale against the original font-size (in pixels)
for each element, so we have to traverse the DOM tree twice —
once to find font-size information and once to apply it.
</p>
<p>
Then, once applied, the font-size is "fixed" — it will no longer
respond to changes in the parent. So class changes triggered by
scripts won't work as expected for font-sizing.
</p>
<p>
The approach taken here mitigates the amount of behavioural modification
as a result of font-size changes. Primarily, whenever the scale is
unset (by choosing —), all font-size changes are reversed so that
full inheritance can again cascade.
</p>
<p>
To see this:
</p>
<ol>
<li>
Set scale to 100% → no change
</li>
<li>
Click 'Change body font size...' link → no change
because font-sizes do not cascade
</li>
<li>
Set scale to — → substantial increase to size of first para
</li>
<li>
Set scale to 100% → no change because calculating off new baseline
</li>
</ol>
</body>
</html>