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