| 123456789101112131415161718192021222324252627282930313233343536373839 |
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="utf-8">
- <title>068 rem line-height</title>
- <style>
- html { font-size: 62.5%; }
- body { background: #ffffff; color: #202020; font-family: sans-serif;
- margin: 12px; font-size: 18px; }
- #a { font-size: 1.8rem; line-height: 2.4rem; margin: 0;
- background: #e0e0ff; }
- #b { font-size: 18px; line-height: 24px; margin: 8px 0 0 0;
- background: #e0ffe0; }
- #result { background: #ffc8c8; color: #000000; padding: 8px;
- margin-top: 12px; }
- </style>
- </head>
- <body>
- <h1>068 — rem line-height</h1>
- <p>With a 10px root, <code>line-height: 2.4rem</code> is 24px, not a 2.4×
- multiplier. Both blocks must be the same height.</p>
- <p id="a">one<br>two<br>three</p>
- <p id="b">one<br>two<br>three</p>
- <div id="result">checking...</div>
- <script>
- setTimeout(function () {
- function R(id) { return document.getElementById(id).getBoundingClientRect(); }
- var a = R('a'), b = R('b');
- var ok = Math.abs(a.height - b.height) <= 2 && a.height < 100;
- var r = document.getElementById('result');
- if (r) {
- r.style.background = ok ? '#c8f0c8' : '#ffc8c8';
- r.textContent = (ok ? 'REMLH-OK ' : 'REMLH-FAIL ') + 'a=' +
- Math.round(a.height) + ' b=' + Math.round(b.height);
- }
- }, 300);
- </script>
- </body>
- </html>
|