position-sticky-stacking-context-002.html (1453B)
1 <!DOCTYPE html> 2 3 <meta charset="UTF-8"> 4 5 <title>CSS Positioned Layout Test: an element with 'position: sticky' creates a stacking context</title> 6 7 <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/"> 8 <link rel="match" href="../../reference/ref-filled-green-100px-square.xht"> 9 <link rel="help" href="https://www.w3.org/TR/css-position-3/#sticky-pos"> 10 11 <meta name="assert" content="This test checks that an element with 'position: sticky' creates a stacking context. In this test, the first 2 divs have the same 'auto' z-index value but since div#sticky is last in document tree order, then it must overlap div#overlapped-red. The final div#overlap-bottom-half-of-sticky exists to make sure that the div#sticky is squeezed, is 'sandwiched' between the other 2."> 12 13 <style> 14 div 15 { 16 height: 100px; 17 width: 100px; 18 } 19 20 div#overlapped-red 21 { 22 background-color: red; 23 position: absolute; 24 } 25 26 div#sticky 27 { 28 background: linear-gradient(to bottom, green 51%, red 49%); 29 position: sticky; 30 } 31 32 div#overlap-bottom-half-of-sticky 33 { 34 background-color: green; 35 bottom: 50px; 36 height: 50px; 37 position: relative; 38 } 39 </style> 40 41 <p>Test passes if there is a filled green square and <strong>no red</strong>. 42 43 <div id="overlapped-red"></div> 44 45 <div id="sticky"></div> 46 47 <div id="overlap-bottom-half-of-sticky"></div>