| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="utf-8">
- <title>061 inline width and intrinsic flex size</title>
- <style>
- body { background: #ffffff; color: #202020; font-family: sans-serif;
- margin: 12px; font-size: 18px; }
- #bar { display: flex; align-items: center; width: 620px; height: 60px;
- overflow: hidden; background: #f4f4f4; }
- #main { z-index: 2; }
- #home { margin: 0 3px 0 0; }
- #homeLink { display: block; padding: 11px 12px; }
- /* the tagesschau mobile icon-only idiom: a 1px inline label */
- #label { display: inline; position: relative; width: 1px; height: 1px;
- overflow: hidden; }
- #sub { width: 100%; overflow: hidden; background: #e8e8ff; }
- #sub ul { list-style: none; margin: 0; padding: 0; display: flex; }
- #sub li { white-space: nowrap; padding: 4px 10px; }
- #result { background: #ffc8c8; color: #000000; padding: 8px;
- margin-top: 12px; }
- </style>
- </head>
- <body>
- <h1>061 — inline width and intrinsic flex size</h1>
- <p>Width/height do not apply to a non-replaced inline box. A 1px inline
- label must not shrink its block ancestor, and the flex row must size the
- left item from the real text width.</p>
- <div id="bar">
- <div id="main">
- <div id="home">
- <a id="homeLink" href="#"><span id="label">Startseite</span></a>
- </div>
- </div>
- <div id="sub"><ul><li>Aigner</li><li>Ukraine</li><li>Klima</li></ul></div>
- </div>
- <div id="result">checking...</div>
- <script>
- setTimeout(function () {
- function R(id) { return document.getElementById(id).getBoundingClientRect(); }
- var main = R('main'), link = R('homeLink');
- var bar = R('bar'), sub = R('sub');
- /* getBoundingClientRect() reports no box for a plain inline span, so
- check that the label is still inline and that its text gave the link
- a text-sized box. */
- var labelInline = getComputedStyle(document.getElementById('label')).display;
- var ok = main.width > 80 &&
- link.width > 80 &&
- labelInline === 'inline' &&
- Math.abs(bar.height - 60) <= 2 &&
- sub.left >= main.right - 2;
- var r = document.getElementById('result');
- if (r) {
- r.style.background = ok ? '#c8f0c8' : '#ffc8c8';
- r.textContent = (ok ? 'INLINE-WIDTH-OK ' : 'INLINE-WIDTH-FAIL ') +
- 'main=' + Math.round(main.width) +
- ' link=' + Math.round(link.width) +
- ' label=' + labelInline +
- ' sub=' + Math.round(sub.left);
- }
- }, 300);
- </script>
- </body>
- </html>
|