background-size-031.html (2522B)
1 <!DOCTYPE html> 2 <html> 3 <head> 4 <meta charset="utf-8"> 5 <title>CSS Backgrounds and Borders Test: background-size '20% 30%' with background-repeat 'no-repeat round'</title> 6 <link rel="author" title="Intel" href="http://www.intel.com"> 7 <link rel="reviewer" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/"> <!-- 2012-11-17 --> 8 <link rel="help" href="http://www.w3.org/TR/css3-background/#the-background-size" title="3.9. Sizing Images: the 'background-size' property"> 9 <link rel="help" href="http://www.w3.org/TR/css3-background/#the-background-repeat" title="3.4. Tiling Images: the 'background-repeat' property"> 10 <link rel="match" href="reference/background-size-031-ref.xht"> 11 12 <meta name="flags" content="image"> 13 <meta name="assert" content="Check if 'background-size' is '20% 30%' and 'background-repeat' is 'no-repeat round', then the height of the corresponding background image is 50px so that it fits a whole number of times (3 in this test) in the background positioning area, and the width of the background image is rescaled to 20% (50px in this test) of the background area."> 14 <meta name="fuzzy" content="maxDifference=1; totalPixels=0-948"> 15 <style> 16 #ref-overlapped-red { 17 background-color: red; 18 height: 150px; 19 width: 50px; 20 } 21 #test-overlapping-square { 22 background-image: url(support/100x100-blue-and-orange.png); 23 background-repeat: no-repeat round; 24 background-size: 20% 30%; 25 bottom: 150px; 26 height: 150px; 27 position: relative; 28 width: 250px; 29 } 30 /* 31 Background positioning area is 250px wide by 150px tall. 32 The width of the background image is 20% of 250px == 50px. 33 The height is rescaled to 30% of 150px == 45px. 34 Then, because background-repeat is set to no-repeat round, the 35 height is rescaled as following: 36 Newest height = 150px / (round [150px / 45px]); 37 Newest height = 150px / (round [3.33]); 38 Newest height = 150px / (3); 39 Newest height = 50px; 40 */ 41 </style> 42 </head> 43 <body> 44 <p>Test passes if there is 1 column of 3 blue-and-orange squares and if there is <strong>no partially</strong> displayed square and <strong>no red</strong>.</p> 45 46 <div id="ref-overlapped-red"></div> 47 <div id="test-overlapping-square"></div> 48 </body> 49 </html>