060-webkit-box.html 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>060 legacy -webkit-box</title>
  6. <style>
  7. body { background: #ffffff; color: #202020; font-family: sans-serif;
  8. margin: 12px; font-size: 18px; }
  9. #box { display: -webkit-box; -webkit-box-orient: vertical;
  10. -webkit-line-clamp: 2; width: 260px; overflow: hidden;
  11. background: #eeeeff; font-size: 24px; }
  12. #result { background: #ffc8c8; color: #000000; padding: 8px;
  13. margin-top: 12px; }
  14. </style>
  15. </head>
  16. <body>
  17. <h1>060 &mdash; legacy -webkit-box</h1>
  18. <p>The line-clamp idiom must render as a normal block so the text keeps its
  19. height and remains visible.</p>
  20. <div id="box"><span>alpha beta</span><span>gamma delta</span></div>
  21. <div id="result">checking...</div>
  22. <script>
  23. setTimeout(function () {
  24. var b = document.getElementById('box');
  25. var r = b.getBoundingClientRect();
  26. var d = getComputedStyle(b).display;
  27. var ok = d === 'block' && r.height > 10 && r.width > 200;
  28. var out = document.getElementById('result');
  29. if (out) {
  30. out.style.background = ok ? '#c8f0c8' : '#ffc8c8';
  31. out.textContent = (ok ? 'WEBKIT-BOX-OK ' : 'WEBKIT-BOX-FAIL ') +
  32. 'display=' + d + ' ' + Math.round(r.width) + 'x' +
  33. Math.round(r.height);
  34. }
  35. }, 300);
  36. </script>
  37. </body>
  38. </html>