OLD | NEW |
| (Empty) |
1 <!DOCTYPE html> | |
2 | |
3 <html> | |
4 <head> | |
5 <style> | |
6 body { | |
7 margin: 0; | |
8 height: 2000px; | |
9 overflow: hidden; /* hide scrollbars */ | |
10 } | |
11 | |
12 .group { | |
13 display: inline-block; | |
14 position: relative; | |
15 width: 250px; | |
16 height: 500px; | |
17 } | |
18 | |
19 .container { | |
20 width: 200px; | |
21 height: 400px; | |
22 outline: 2px solid black; | |
23 } | |
24 | |
25 .box { | |
26 width: 200px; | |
27 height: 200px; | |
28 } | |
29 | |
30 .sticky { | |
31 position: sticky; | |
32 top: 100px; | |
33 background-color: silver; | |
34 } | |
35 | |
36 .child { | |
37 position: absolute; | |
38 background-color: green; | |
39 top: 50px; | |
40 left: 50px; | |
41 } | |
42 | |
43 .indicator { | |
44 position: absolute; | |
45 top: 250px; | |
46 left: 50px; | |
47 background-color: red; | |
48 } | |
49 </style> | |
50 <script> | |
51 function doTest() | |
52 { | |
53 window.scrollTo(0, 100); | |
54 } | |
55 window.addEventListener('load', doTest, false); | |
56 </script> | |
57 </head> | |
58 <body> | |
59 <div class="group"> | |
60 <div class="indicator box"></div> | |
61 <div class="container"> | |
62 <div class="sticky box"> | |
63 <div class="child box"></div> | |
64 </div> | |
65 </div> | |
66 </div> | |
67 | |
68 </body> | |
69 </html> | |
OLD | NEW |