| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- <!doctype html>
- <html>
- <head>
- <meta charset="utf-8">
- <title>046 flex footer and query selectors</title>
- <style>
- html, body { margin: 0; padding: 0; background: #f6f6ef; color: #202020; }
- body { font-family: sans-serif; font-size: 13px; padding: 10px; }
- h1 { font-size: 20px; margin: 0 0 6px 0; }
- p { margin: 0 0 10px 0; }
- .nav { clear: both; overflow: hidden; margin-bottom: 14px; }
- .nav ul { float: right; margin: 0; padding: 0; list-style: none; }
- .nav li { float: left; margin-left: 8px; }
- .nav a { display: block; color: #404040; padding: 10px 15px; text-decoration: none; }
- .nav a.btn { background: #28cb75; color: #ffffff; font-weight: bold;
- border: 2px solid #28cb75; border-radius: 20px; }
- .flexfooter { display: flex; flex-direction: row; justify-content: space-evenly;
- max-width: 1000px; margin: 0 auto; text-align: left;
- flex-wrap: wrap; background: #494f5a; color: #ffffff;
- padding: 20px; }
- .list h3 { color: #acacac; margin: 0 0 10px 0; }
- .list a { display: block; color: #ffffff; margin-bottom: 4px; text-decoration: none; }
- .list.wide a { white-space: nowrap; }
- #result { margin-top: 14px; padding: 8px; background: #eeeeee; color: #000000;
- font-family: monospace; font-weight: bold; }
- </style>
- </head>
- <body>
- <h1>046 · flex footer and query selectors</h1>
- <p>The three footer columns must sit on one row with equal space, and the padded Install button must stay on one line.</p>
- <div class="nav">
- <ul>
- <li><a href="#">Demo</a></li>
- <li><a href="#">Docs</a></li>
- <li><a class="btn" id="install" href="#">Install</a></li>
- <li><a href="#">My Account</a></li>
- </ul>
- </div>
- <div class="flexfooter" id="footer">
- <div class="list wide" id="l1"><h3>About</h3><a href="#">Story</a><a href="#">Open Source</a><a href="#">Imprint</a><a href="#">Brand Assets</a><a href="#">Data Processing Agreement</a></div>
- <div class="list" id="l2"><h3>Resources</h3><a href="#">Blog</a><a href="#">Documentation</a><a href="#">Forum</a><a href="#">Pricing</a><a href="#">Community apps</a><a href="#">App Status</a></div>
- <div class="list" id="l3"><h3>Follow us</h3><a href="#">Forum</a><a href="#">Mastodon</a><a href="#">RSS</a></div>
- </div>
- <div id="result">checking...</div>
- <script>
- setTimeout(function () {
- var lists = document.querySelectorAll('.list');
- var b1 = document.getElementById('l1').getBoundingClientRect();
- var b2 = document.getElementById('l2').getBoundingClientRect();
- var b3 = document.getElementById('l3').getBoundingClientRect();
- var ins = document.getElementById('install');
- var ir = ins.getBoundingClientRect();
- var q = document.querySelector('a.btn');
- var details = [];
- var ok = lists.length === 3;
- if (!ok) details.push('list count=' + lists.length);
- if (lists.length && lists[0].tagName !== 'DIV') {
- ok = false; details.push('query element tag=' + lists[0].tagName);
- }
- if (!q || q.tagName !== 'A' || q.textContent !== 'Install') {
- ok = false; details.push('querySelector anchor');
- }
- if (Math.abs(b1.top - b2.top) > 1 || Math.abs(b2.top - b3.top) > 1) {
- ok = false; details.push('footer rows differ');
- }
- var gap1 = b2.left - b1.right;
- var gap2 = b3.left - b2.right;
- if (Math.abs(gap1 - gap2) > 3) {
- ok = false; details.push('gaps ' + Math.round(gap1) + '/' + Math.round(gap2));
- }
- if (ir.height > 50 || ir.width < 70) {
- ok = false; details.push('install ' + Math.round(ir.width) + 'x' + Math.round(ir.height));
- }
- var out = document.getElementById('result');
- out.textContent = ok ? 'PASS: footer columns, padding and query selectors' :
- ('FAIL: ' + details.join('; '));
- out.style.background = ok ? '#ccffcc' : '#ffcccc';
- }, 600);
- </script>
- </body>
- </html>
|