| 1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="utf-8">
- <title>053 background shorthand position and size</title>
- <style>
- body { background: #ffffff; color: #202020; font-family: sans-serif;
- margin: 12px; font-size: 18px; }
- .tile { width: 220px; height: 130px; border: 2px solid #202020;
- margin: 8px 0; }
- #a { background: #ffffff url(TILE.PNG) center/cover no-repeat; }
- #b { background: url(TILE.PNG) left top/50px 30px no-repeat; }
- #c { background: #204080 url(TILE.PNG) no-repeat right bottom / 100% 50%; }
- </style>
- </head>
- <body>
- <h1>053 — background shorthand</h1>
- <p>The position before the slash and the size after it must both survive the
- shorthand parser. The image is <code>TILE.PNG</code>.</p>
- <div id="a" class="tile"></div>
- <div id="b" class="tile"></div>
- <div id="c" class="tile"></div>
- <div id="result" style="background: #c8f0c8; color: #000000; padding: 8px;
- font-size: 18px;">checking...</div>
- <script>
- setTimeout(function () {
- function P(id) { return getComputedStyle(document.getElementById(id)).backgroundPosition; }
- function S(id) { return getComputedStyle(document.getElementById(id)).backgroundSize; }
- var a = P('a') + ' / ' + S('a');
- var b = P('b') + ' / ' + S('b');
- var c = P('c') + ' / ' + S('c');
- var ok = a === '50% 50% / cover' &&
- b === '0% 0% / 50px 30px' &&
- c === '100% 100% / 100% 50%';
- var r = document.getElementById('result');
- if (r) {
- r.style.background = ok ? '#c8f0c8' : '#ffc8c8';
- r.textContent = (ok ? 'BACKGROUND-OK ' : 'BACKGROUND-FAIL ') +
- 'a[' + a + '] b[' + b + '] c[' + c + ']';
- }
- }, 300);
- </script>
- </body>
- </html>
|