| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="utf-8">
- <title>049 table width and alignment</title>
- <style>
- body { background: #ffffff; color: #202020; font-family: sans-serif;
- margin: 8px; }
- table { border: 1px solid #404040; border-collapse: collapse; }
- td { padding: 4px; font-size: 16px; }
- </style>
- </head>
- <body>
- <h1>049 — table width and alignment</h1>
- <p>The outer table is 85% of the body; its single-column cell fills that
- width. The nested table is 100% of the cell. Cell text stays left-aligned
- even inside <code><center></code>, and <code>align="right"</code>
- right-aligns the rank column.</p>
- <center>
- <table id="outer" width="85%">
- <tr><td id="outercell" style="background: #ffdddd">OUTER CELL FILLS 85%</td></tr>
- <tr><td>
- <table id="story" width="100%">
- <tr>
- <td id="rank" align="right" style="background: #ffeecc">1.</td>
- <td style="background: #eeeeff">vote</td>
- <td style="background: #eeffee">NESTED TITLE FILLS THE CELL</td>
- </tr>
- </table>
- </td></tr>
- </table>
- </center>
- <div id="result" style="background: #ffc8c8; color: #000000; padding: 8px;
- font-size: 18px;">checking...</div>
- <script>
- setTimeout(function () {
- var body = document.body.getBoundingClientRect();
- var outer = document.getElementById('outer').getBoundingClientRect();
- var cell = document.getElementById('outercell').getBoundingClientRect();
- var story = document.getElementById('story').getBoundingClientRect();
- var rank = document.getElementById('rank').getBoundingClientRect();
- var want = body.width * 85 / 100;
- var ok = Math.abs(outer.width - want) <= 12;
- ok = ok && Math.abs(cell.width - outer.width) <= 12;
- ok = ok && Math.abs(story.width - outer.width) <= 16;
- ok = ok && rank.width < outer.width / 2;
- var r = document.getElementById('result');
- if (r) {
- r.style.background = ok ? '#c8f0c8' : '#ffc8c8';
- r.textContent = (ok ? 'TABLE-OK ' : 'TABLE-FAIL ') +
- 'body=' + Math.round(body.width) +
- ' outer=' + Math.round(outer.width) +
- ' cell=' + Math.round(cell.width) +
- ' story=' + Math.round(story.width) +
- ' rank=' + Math.round(rank.width);
- }
- }, 300);
- </script>
- </body>
- </html>
|