| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="utf-8">
- <title>063 leading-dot CSS lengths</title>
- <style>
- html { font-size: 62.5%; }
- body { background: #ffffff; color: #202020; font-family: sans-serif;
- margin: 12px; font-size: 18px; }
- #box { margin: 0 .5rem; padding: .3rem .7rem; border-radius: .8rem;
- width: 10rem; height: 3rem; line-height: .9;
- background: #eeeeff; }
- #b { border: .2rem solid #333333; }
- #result { background: #ffc8c8; color: #000000; padding: 8px;
- margin-top: 12px; }
- </style>
- </head>
- <body>
- <h1>063 — leading-dot CSS lengths</h1>
- <p>Minified stylesheets write fractional lengths as <code>.5rem</code> rather
- than <code>0.5rem</code>; every length parser must accept that.</p>
- <div id="box">box</div>
- <div id="b">bordered</div>
- <div id="result">checking...</div>
- <script>
- setTimeout(function () {
- var b = document.getElementById('box');
- var cs = getComputedStyle(b);
- var r = b.getBoundingClientRect();
- var bb = document.getElementById('b');
- var bw = getComputedStyle(bb).borderTopWidth;
- var ok = cs.marginLeft === '5px' &&
- cs.paddingLeft === '7px' &&
- cs.paddingTop === '3px' &&
- Math.abs(r.width - 114) <= 2 &&
- Math.abs(r.height - 36) <= 2 &&
- bw === '2px';
- var out = document.getElementById('result');
- if (out) {
- out.style.background = ok ? '#c8f0c8' : '#ffc8c8';
- out.textContent = (ok ? 'LEADING-DOT-OK ' : 'LEADING-DOT-FAIL ') +
- 'm=' + cs.marginLeft + ' p=' + cs.paddingTop + '/' +
- cs.paddingLeft +
- ' ' + Math.round(r.width) + 'x' + Math.round(r.height) +
- ' border=' + bw;
- }
- }, 300);
- </script>
- </body>
- </html>
|