OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 |
2 <html> | 3 <html> |
3 <head> | 4 <head> |
4 <style> | 5 <style> |
5 .group { | 6 .group { |
6 display: inline-block; | 7 display: inline-block; |
7 position: relative; | 8 position: relative; |
8 width: 150px; | 9 width: 150px; |
9 height: 500px; | 10 height: 500px; |
10 } | 11 } |
11 | 12 |
12 #overflow { | 13 #overflow { |
13 width: 600px; | 14 width: 600px; |
14 height: 550px; | 15 height: 400px; |
15 overflow: hidden; /* Still scrollable with JS */ | 16 overflow: hidden; /* Still scrollable with JS */ |
| 17 padding: 20px; |
16 border: 1px solid black; | 18 border: 1px solid black; |
17 } | 19 } |
18 | 20 |
19 .spacer { | 21 .spacer { |
20 float: left; | 22 float: left; |
21 width: 10px; | 23 width: 10px; |
22 height: 1200px; | 24 height: 1200px; |
23 } | 25 } |
24 .container { | 26 .container { |
25 width: 100px; | 27 width: 100px; |
26 height: 400px; | 28 height: 300px; |
27 outline: 2px solid black; | 29 outline: 2px solid black; |
28 } | 30 } |
29 | 31 |
30 .box { | 32 .box { |
31 width: 100px; | 33 width: 100px; |
32 height: 200px; | 34 height: 150px; |
33 } | 35 } |
34 | 36 |
35 .sticky { | 37 .sticky { |
36 position: sticky; | 38 position: sticky; |
37 top: 100px; | 39 bottom: 0px; |
38 background-color: green; | 40 background-color: green; |
39 } | 41 } |
40 | 42 |
41 .indicator { | 43 .indicator { |
42 position: absolute; | 44 position: absolute; |
43 top: 0; | 45 top: 0; |
44 left: 0; | 46 left: 0; |
45 background-color: red; | 47 background-color: red; |
46 } | 48 } |
47 </style> | 49 </style> |
48 <script> | 50 <script> |
49 function doTest() | 51 function doTest() |
50 { | 52 { |
51 document.getElementById('overflow').scrollTop = 120; | 53 document.getElementById('overflow').scrollTop = 100; |
52 } | 54 } |
53 window.addEventListener('load', doTest, false); | 55 window.addEventListener('load', doTest, false); |
54 </script> | 56 </script> |
55 </head> | 57 </head> |
56 <body> | 58 <body> |
57 This test checks that sticky positioned elements are contained by their enclosin
g ancestor with an overflow clip. | |
58 There should be no red. | |
59 <div id="overflow"> | 59 <div id="overflow"> |
60 <div class="spacer"></div> | 60 <div class="spacer"></div> |
61 <div class="group"> | 61 <div class="group" style="top: 350px"> |
62 <div class="indicator box" style="top: 200px;"></div> | 62 <div class="indicator box" style="top: 0px;"></div> |
63 <div class="container"> | 63 <div class="container"> |
| 64 <div class="box"></div> |
64 <div class="sticky box"></div> | 65 <div class="sticky box"></div> |
65 </div> | 66 </div> |
66 </div> | 67 </div> |
67 | 68 |
68 <div class="group" style="top: 100px"> | 69 <div class="group" style="top: 250px"> |
69 <div class="indicator box" style="top: 120px;"></div> | 70 <div class="indicator box" style="top: 100px;"></div> |
70 <div class="container"> | 71 <div class="container"> |
| 72 <div class="box"></div> |
71 <div class="sticky box"></div> | 73 <div class="sticky box"></div> |
72 </div> | 74 </div> |
73 </div> | 75 </div> |
74 | 76 |
75 <div class="group" style="top: 240px"> | 77 <div class="group" style="top: 200px"> |
76 <div class="indicator box" style="top: 0;"></div> | 78 <div class="indicator box" style="top: 150px;"></div> |
77 <div class="container"> | 79 <div class="container"> |
| 80 <div class="box"></div> |
78 <div class="sticky box"></div> | 81 <div class="sticky box"></div> |
79 </div> | 82 </div> |
80 </div> | 83 </div> |
81 </div> | 84 </div> |
| 85 <div style="position: absolute; top: 500px;"> |
| 86 This test checks that sticky positioned blocks positioned correctly in overf
low with padding. |
| 87 There should be no red. |
| 88 </div> |
82 </body> | 89 </body> |
83 </html> | 90 </html> |
OLD | NEW |