OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <html> |
| 3 <head> |
| 4 <script src="js/dom-util.js"></script> |
| 5 <script src="js/viewport-observer.js"></script> |
| 6 <script src="js/sticky.js"></script> |
| 7 <style> |
| 8 .sticky { |
| 9 display: inline-block; |
| 10 width: 100px; |
| 11 height: 100px; |
| 12 border: 3px solid black; |
| 13 } |
| 14 |
| 15 body { |
| 16 background-color: #aaa; |
| 17 width: 3000px; |
| 18 height: 3000px; |
| 19 } |
| 20 |
| 21 .sticky-content { |
| 22 background-color: white; |
| 23 width: 2000px; |
| 24 height: 2000px; |
| 25 margin: 500px; |
| 26 } |
| 27 |
| 28 .top { |
| 29 top: 20px; |
| 30 } |
| 31 |
| 32 #red { |
| 33 background-color: red; |
| 34 } |
| 35 .left { |
| 36 left: 20px; |
| 37 } |
| 38 |
| 39 #blue { |
| 40 background-color: blue; |
| 41 } |
| 42 |
| 43 .right { |
| 44 right: 20px; |
| 45 } |
| 46 |
| 47 #green { |
| 48 background-color: green; |
| 49 } |
| 50 |
| 51 .bottom { |
| 52 bottom: 20px; |
| 53 } |
| 54 |
| 55 #yellow { |
| 56 background-color: yellow; |
| 57 } |
| 58 </style> |
| 59 </head> |
| 60 <body> |
| 61 <div class="sticky-content"> |
| 62 <div id="red" class="sticky left">Left sticky</div> |
| 63 <div id="blue" class="sticky right">Right sticky</div> |
| 64 <div id="green" class="sticky bottom">Bottom sticky</div> |
| 65 <div id="yellow" class="sticky top">Top sticky</div> |
| 66 </div> |
| 67 </body> |
| 68 </html> |
OLD | NEW |