background-size-009

background-size - one value

WeasyPrint

Reference (good) by WeasyPrint

Reference (good) by this browser

This browser

Flags
image
Assertion
Check if 'background-size' has only one percentage value, then such value is the width of the corresponding image and the second value (corresponding to the height of the background image) is assumed to be 'auto'. A percentage is relative to the dimensions of the background positioning area. An 'auto' value for one dimension is resolved by using the image's intrinsic ratio (in this test, the image's intrinsic ratio is 1:1) and (multiplied by) the size of the other dimension. Therefore the used height of the background-size in this test should be 45px.

Source

 1 <!DOCTYPE html>
 2 <html><head>
 3     <meta charset="utf-8">
 4     <title>CSS Backgrounds and Borders Test: background-size - one &lt;percentage&gt; value</title>
 5     <link href="http://www.intel.com" rel="author" title="Intel">
 6     <link href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" rel="reviewer" title="Gérard Talbot"> <!-- 2012-11-09 -->
 7     <link href="http://www.w3.org/TR/css3-background/#the-background-size" rel="help" title="3.9. Sizing Images: the 'background-size' property">
 8     <link href="reference/background-size-006-ref.htm" rel="match">
 9     <meta content="image" name="flags">
10     <meta content="Check if 'background-size' has only one percentage value, then such value is the width of the corresponding image and the second value (corresponding to the height of the background image) is assumed to be 'auto'. A percentage is relative to the dimensions of the background positioning area. An 'auto' value for one dimension is resolved by using the image's intrinsic ratio (in this test, the image's intrinsic ratio is 1:1) and (multiplied by) the size of the other dimension. Therefore the used height of the background-size in this test should be 45px." name="assert">
11     <style>
12         #ref-overlapped-red {
13             background-color: red;
14             height: 45px;
15             width: 45px;
16         }
17         #test-overlapping-green {
18             background-image: url(support/60x60-green.png);
19             background-repeat: no-repeat;
20             background-size: 45%;
21             bottom: 45px;
22             height: 50px;
23             position: relative;
24             width: 100px;
25         }
26 
27         /*
28         background-size: 45% is relative to the background positioning area
29         which is 100px by 100px in this test.
30         */
31     </style>
32   </head>
33   <body>
34     <p>Test passes if there is a filled green square and <strong>no red</strong>.</p>
35     <div id="ref-overlapped-red"></div>
36     <div id="test-overlapping-green"></div>
37   
38 
39 </body></html>