background-size-contain-002.html (1966B)
1 <!DOCTYPE html> 2 <html> 3 <head> 4 <meta charset="UTF-8"> 5 6 <title>CSS Backgrounds and Borders Test: background-size - contain keyword value</title> 7 8 <link rel="author" title="Intel" href="http://www.intel.com"> 9 <link rel="reviewer" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/"> <!-- 2012-11-08 --> 10 <!-- 11 http://www.gtalbot.org/BrowserBugsSection/review/background-size-contain-002-review.html 12 --> 13 <link rel="help" href="http://www.w3.org/TR/css3-background/#the-background-size" title="3.9. Sizing Images: the 'background-size' property"> 14 <link rel="match" href="../reference/ref-filled-green-100px-square.xht"> 15 16 <meta name="flags" content="image"> 17 <meta name="assert" content="Check if 'background-size' is 'contain' that it scales the background-image, while preserving its intrinsic aspect ratio (it is 1:1 in this test), to the largest size such that both its width and its height can fit inside the background positioning area. In this test, the background-image should be scaled to become 100px by 100px."> 18 <style> 19 div#ref-overlapped-red 20 { 21 background-color: red; 22 height: 100px; 23 width: 100px; 24 } 25 26 div#test-overlapping-green 27 { 28 background-image: url("support/50x50-green.png"); 29 background-repeat: no-repeat; 30 background-size: contain; 31 bottom: 100px; 32 height: 150px; 33 padding: 25px; 34 position: relative; 35 width: 50px; 36 37 /* 38 Background positioning area is 100px wide by 200px tall. 39 So, the image should be scaled to 100px by 100px. 40 */ 41 } 42 </style> 43 </head> 44 <body> 45 <p>Test passes if there is a filled green square and <strong>no red</strong>.</p> 46 <div id="ref-overlapped-red"></div> 47 <div id="test-overlapping-green"></div> 48 </body> 49 </html>