| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="utf-8">
- <title>056 details summary</title>
- <style>
- body { background: #ffffff; color: #202020; font-family: sans-serif;
- margin: 12px; font-size: 18px; }
- summary { background: #eeeeff; padding: 6px; }
- #hidden-content { background: #ffdddd; padding: 6px; }
- #open-content { background: #ddffdd; padding: 6px; }
- #result { background: #ffc8c8; color: #000000; padding: 8px;
- margin-top: 12px; }
- </style>
- </head>
- <body>
- <h1>056 — closed details keeps its summary</h1>
- <p>A closed <code><details></code> must keep the summary (the hamburger
- button on many news sites) in the layout and hide only the rest.</p>
- <details id="closed">
- <summary id="closed-summary">CLOSED SUMMARY</summary>
- <div id="hidden-content">THIS MUST BE HIDDEN</div>
- </details>
- <details id="open" open>
- <summary id="open-summary">OPEN SUMMARY</summary>
- <div id="open-content">THIS MUST BE VISIBLE</div>
- </details>
- <div id="result">checking...</div>
- <script>
- setTimeout(function () {
- var s = document.getElementById('closed-summary');
- var h = document.getElementById('hidden-content');
- var o = document.getElementById('open-content');
- var sr = s.getBoundingClientRect();
- var hd = getComputedStyle(h).display;
- var od = getComputedStyle(o).display;
- var ok = sr.width > 50 && sr.height > 0 &&
- hd === 'none' && od !== 'none';
- var r = document.getElementById('result');
- if (r) {
- r.style.background = ok ? '#c8f0c8' : '#ffc8c8';
- r.textContent = (ok ? 'DETAILS-OK ' : 'DETAILS-FAIL ') +
- 'summary=' + Math.round(sr.width) + 'x' +
- Math.round(sr.height) +
- ' hidden=' + hd + ' open=' + od;
- }
- }, 300);
- </script>
- </body>
- </html>
|