OLD | NEW |
| (Empty) |
1 <!DOCTYPE html> | |
2 | |
3 <html> | |
4 <head> | |
5 <style> | |
6 body { | |
7 margin: 0; | |
8 } | |
9 | |
10 .group { | |
11 display: inline-block; | |
12 position: relative; | |
13 width: 180px; | |
14 height: 500px; | |
15 } | |
16 | |
17 .container { | |
18 position: relative; | |
19 width: 150px; | |
20 height: 400px; | |
21 border: 2px solid black; | |
22 padding: 5px; | |
23 } | |
24 | |
25 .box { | |
26 width: 120px; | |
27 height: 120px; | |
28 } | |
29 | |
30 .sticky { | |
31 position: relative; | |
32 background-color: green; | |
33 } | |
34 | |
35 .indicator { | |
36 position: absolute; | |
37 top: 0; | |
38 left: 37px; | |
39 background-color: red; | |
40 } | |
41 </style> | |
42 </head> | |
43 <body> | |
44 <!-- auto margins --> | |
45 <div class="group" style="top: -300px"> | |
46 <div class="indicator box" style="top: 110px;"></div> | |
47 <div class="container"> | |
48 <div class="sticky box" style="margin: auto; top: 280px"></div> | |
49 </div> | |
50 </div> | |
51 | |
52 <!-- px margins --> | |
53 <div class="group" style="top: -300px"> | |
54 <div class="indicator box" style="top: 37px;"></div> | |
55 <div class="container"> | |
56 <div class="sticky box" style="margin: 20px; top: 240px"></div> | |
57 </div> | |
58 </div> | |
59 | |
60 <!-- % margins --> | |
61 <div class="group" style="top: -300px"> | |
62 <div class="indicator box" style="top: 37px;"></div> | |
63 <div class="container"> | |
64 <div class="sticky box" style="margin: 20%; top: 220px"></div> | |
65 </div> | |
66 </div> | |
67 | |
68 <!-- % margins --> | |
69 <div class="group" style="top: -300px"> | |
70 <div class="indicator box" style="top: 37px;"></div> | |
71 <div class="container" style="width: 200px;"> | |
72 <div class="sticky box" style="margin: 20%; top: 200px"></div> | |
73 </div> | |
74 </div> | |
75 </body> | |
76 </html> | |
OLD | NEW |