050-font-shorthand.html 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>050 font shorthand</title>
  6. <style>
  7. html { font-size: 10px; }
  8. body { background: #ffffff; color: #202020; font-family: sans-serif; }
  9. #a { font: 20px/1 Verdana, sans-serif; }
  10. #b { font: bold 22px/1.4 monospace; }
  11. #c { font: italic 18px/1.2 Verdana; }
  12. #d { font-size: 24px; }
  13. </style>
  14. </head>
  15. <body>
  16. <h1>050 &mdash; font shorthand</h1>
  17. <p>A family token after the size must not erase the parsed size, and the
  18. line-height/weight/style tokens must survive.</p>
  19. <div id="a">A: 20px family</div>
  20. <div id="b">B: bold 22px mono</div>
  21. <div id="c">C: italic 18px</div>
  22. <div id="d">D: 24px longhand control</div>
  23. <div id="result" style="background: #ffc8c8; color: #000000; padding: 8px;
  24. margin-top: 12px; font-size: 18px;">checking...</div>
  25. <script>
  26. setTimeout(function () {
  27. function size(id) { return getComputedStyle(document.getElementById(id)).fontSize; }
  28. var a = size('a'), b = size('b'), c = size('c'), d = size('d');
  29. var ok = a === '20px' && b === '22px' && c === '18px' && d === '24px';
  30. var r = document.getElementById('result');
  31. if (r) {
  32. r.style.background = ok ? '#c8f0c8' : '#ffc8c8';
  33. r.textContent = (ok ? 'FONT-OK ' : 'FONT-FAIL ') +
  34. 'a=' + a + ' b=' + b + ' c=' + c + ' d=' + d;
  35. }
  36. }, 300);
  37. </script>
  38. </body>
  39. </html>