background-attachment-353.html (3963B)
1 <!DOCTYPE html> 2 <html class="reftest-wait"> 3 <meta charset="UTF-8"> 4 5 <title>CSS Background and Borders Test: 'background-attachment: local' and 'overflow: hidden'</title> 6 7 <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/"> 8 <link rel="help" href="http://www.w3.org/TR/css3-background/#the-background-attachment"> 9 <link rel="match" href="../reference/ref-filled-green-100px-square.xht"> 10 <script src="/common/reftest-wait.js"></script> 11 <link rel="preload" as="image" href="support/100x100-gr-rr.png" onload="takeScreenshot()" /> 12 <link rel="stylesheet" type="text/css" href="/fonts/ahem.css"> 13 14 <!-- 15 16 More info: 17 18 Re: [css3-background] background-attachment: local 19 http://lists.w3.org/Archives/Public/www-style/2013May/0542.html 20 21 --> 22 23 <meta content="This test checks that when an element has 'background-attachment: local', then the background image is fixed with regard to what is the element's scrollable area and not to its viewport. In this test, what would be the scrollable area for the div#target element is where the red area of its background image 100x100-gr-rr.png is and such area is clipped due to 'overflow: hidden'." name="assert"> 24 25 <style> 26 div#control 27 { 28 background-color: red; 29 border: solid green; 30 border-width: 50px 0 0 50px; 31 height: 50px; 32 margin-bottom: -100px; 33 width: 50px; 34 } 35 36 div#target 37 { 38 background-attachment: local; 39 background-image: url("support/100x100-gr-rr.png"); 40 background-repeat: no-repeat; 41 background-position: center; 42 font-family: Ahem; 43 font-size: 100px; 44 line-height: 1; 45 height: 100px; 46 overflow: hidden; 47 width: 100px; 48 } 49 </style> 50 51 <body> 52 53 <p>Test passes if there is a filled green square and <strong>no red</strong>. 54 55 <div id="control"></div> 56 57 <div id="target"> <br> </div> 58 59 <!-- 60 61 div#control is 62 63 (0px, 0px) (100px, 0px) 64 +.......................+ 65 | | 66 | | 67 | green area | 68 | | 69 | | 70 | green area | 71 | | 72 | +........+| 73 | green | red || 74 | area | area || 75 | | || 76 | +........+| 77 +.......................+ 78 (0px, 100px) (100px, 100px) 79 80 81 = = = = = = = 82 83 84 div#target with background-position: top left 85 86 (0px, 0px) (100px, 0px) 87 +.......................+ 88 | +........+ | 89 | | green | red | 90 | | area | area | 91 | | | | 92 | +........+ | 93 | | 94 | red area | 95 | | 96 | | 97 | red area | 98 | | 99 | | 100 +.......................+ 101 (0px, 100px) (100px, 100px) 102 103 104 = = = = = = = 105 106 107 div#target with background-position: center 108 109 (0px, 0px) (100px, 0px) 110 +.......................+ 111 | | 112 | green area | 113 | | overflowed 114 | | area 115 | green area | | 116 | | V 117 | +...........| ...........+ 118 | | +........+| | 119 | green | | green || red | 120 | area | | area || area | 121 | | | || | 122 | | +........+| | 123 +.......................+ | 124 | | 125 | red area | <== overflowed 126 | | <== area 127 | red area | 128 | | 129 | | 130 +.........................+ 131 132 -->