position-sticky-right-002.html (2796B)
1 <!DOCTYPE html> 2 3 <meta charset="UTF-8"> 4 5 <title>CSS Position Test: sticky element with right offset specified with px unit</title> 6 7 <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/"> 8 <link rel="help" href="https://www.w3.org/TR/css-position-3/#sticky-pos"> 9 <link rel="match" href="reference/position-sticky-right-002-ref.html"> 10 11 <meta name="flags" content=""> 12 13 <style> 14 div.scrolling-container 15 { 16 background-image: url("support/100x100-red.png"); 17 background-repeat: no-repeat; 18 height: 150px; 19 margin-bottom: 30px; 20 overflow-y: hidden; 21 position: static; 22 white-space: nowrap; 23 width: 250px; 24 } 25 26 div#first-scrolling-container 27 { 28 background-position: 75px top; 29 } 30 31 div#second-scrolling-container 32 { 33 background-position: 50px top; 34 } 35 36 div#third-scrolling-container 37 { 38 background-position: left top; 39 } 40 41 div.horizontal-spacer 42 { 43 display: inline-block; 44 height: 100%; 45 width: 100px; 46 } 47 48 div.content 49 { 50 display: inline-block; 51 height: 100%; 52 width: 300px; 53 } 54 55 div.sticky 56 { 57 background-color: green; 58 display: inline-block; 59 height: 100px; 60 position: sticky; 61 right: 100px; 62 vertical-align: top; 63 width: 100px; 64 } 65 </style> 66 67 <body onload="document.getElementById("first-scrolling-container").scrollLeft = 25; document.getElementById("second-scrolling-container").scrollLeft = 100; document.getElementById("third-scrolling-container").scrollLeft = 200;"> 68 69 <p>Test passes if there are 3 filled green squares and <strong>no red</strong>. 70 71 <!-- 72 first-scrolling-container: before reaching the sticking point 73 --> 74 75 <div id="first-scrolling-container" class="scrolling-container"> 76 77 <div class="horizontal-spacer"></div><div class="content"><div class="horizontal-spacer"></div><div id="first-sticky" class="sticky"></div><div class="horizontal-spacer"></div></div><div class="horizontal-spacer"></div> 78 79 </div> 80 81 <!-- 82 second-scrolling-container: when reaching the sticking point and beyond 83 --> 84 85 <div id="second-scrolling-container" class="scrolling-container"> 86 87 <div class="horizontal-spacer"></div><div class="content"><div class="horizontal-spacer"></div><div id="second-sticky" class="sticky"></div><div class="horizontal-spacer"></div></div><div class="horizontal-spacer"></div> 88 89 </div> 90 91 92 <div id="third-scrolling-container" class="scrolling-container"> 93 94 <div class="horizontal-spacer"></div><div class="content"><div class="horizontal-spacer"></div><div id="third-sticky" class="sticky"></div><div class="horizontal-spacer"></div></div><div class="horizontal-spacer"></div> 95 96 </div>