| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="utf-8">
- <title>062 flex container on an inline element</title>
- <style>
- body { background: #ffffff; color: #202020; font-family: sans-serif;
- margin: 12px; font-size: 18px; }
- /* an <a> is inline by tag but a flex container is block-level */
- #card { display: flex; width: 520px; background: #eeeeee; }
- #thumb { width: 90px; height: 90px; background: #cccccc; }
- #body { flex-grow: 1; }
- #h { margin: 0 0 4px; font-size: 22px; }
- #p { margin: 0; }
- #after { background: #ddffdd; }
- #result { background: #ffc8c8; color: #000000; padding: 8px;
- margin-top: 12px; }
- </style>
- </head>
- <body>
- <h1>062 — flex container on an inline element</h1>
- <p>A link card uses <code><a style="display:flex"></code>: the link must
- get a block-level box with a real height and the next block must start
- below it.</p>
- <a id="card" href="#">
- <div id="thumb"></div>
- <div id="body"><h2 id="h">Headline</h2><p id="p">Teaser text body</p></div>
- </a>
- <div id="after">after the card</div>
- <div id="result">checking...</div>
- <script>
- setTimeout(function () {
- function R(id) { return document.getElementById(id).getBoundingClientRect(); }
- var card = R('card'), body = R('body'), h = R('h'), after = R('after');
- var ok = card.height >= 88 &&
- card.width >= 500 &&
- body.width > 350 &&
- h.height > 10 &&
- after.top >= card.bottom - 1;
- var r = document.getElementById('result');
- if (r) {
- r.style.background = ok ? '#c8f0c8' : '#ffc8c8';
- r.textContent = (ok ? 'FLEX-LINK-OK ' : 'FLEX-LINK-FAIL ') +
- 'card=' + Math.round(card.width) + 'x' +
- Math.round(card.height) +
- ' body=' + Math.round(body.width) +
- ' h=' + Math.round(h.height) +
- ' after=' + Math.round(after.top);
- }
- }, 300);
- </script>
- </body>
- </html>
|