| OLD | NEW |
| 1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 | 2 <style type="text/css"> |
| 3 <html> | 3 div { |
| 4 <head> | 4 height: 100px; |
| 5 <style> | 5 width: 100px; |
| 6 body { | 6 } |
| 7 margin: 0; | 7 .spacer { |
| 8 } | 8 background-color: red; |
| 9 | 9 } |
| 10 .group { | 10 .sticky { |
| 11 display: inline-block; | 11 background-color: green; |
| 12 position: relative; | 12 position: relative; |
| 13 width: 250px; | 13 } |
| 14 height: 500px; | 14 .absoffset { |
| 15 } | 15 background-color: green; |
| 16 | 16 position: absolute; |
| 17 .container { | 17 top: -100px; |
| 18 width: 200px; | 18 } |
| 19 height: 400px; | |
| 20 outline: 2px solid black; | |
| 21 } | |
| 22 | |
| 23 .box { | |
| 24 width: 200px; | |
| 25 height: 200px; | |
| 26 } | |
| 27 | |
| 28 .sticky { | |
| 29 position: relative; | |
| 30 top: 200px; | |
| 31 background-color: silver; | |
| 32 } | |
| 33 | |
| 34 .child { | |
| 35 position: absolute; | |
| 36 background-color: green; | |
| 37 top: 50px; | |
| 38 left: 50px; | |
| 39 } | |
| 40 | |
| 41 .indicator { | |
| 42 position: absolute; | |
| 43 top: 250px; | |
| 44 left: 50px; | |
| 45 background-color: red; | |
| 46 } | |
| 47 </style> | 19 </style> |
| 48 </head> | 20 <div class="spacer"></div> |
| 49 <body> | 21 <div class="sticky"> |
| 50 <div class="group" style="top: -100px;"> | 22 <!-- |
| 51 <div class="indicator box"></div> | 23 Tests that the absolute positioned child is positioned relative to the stick
y container. You should see only a |
| 52 <div class="container"> | 24 green box as this will cover up the red box above the sticky div. |
| 53 <div class="sticky box"> | 25 --> |
| 54 <div class="child box"></div> | 26 <div class="absoffset"></div> |
| 55 </div> | 27 </div> |
| 56 </div> | |
| 57 </div> | |
| 58 | |
| 59 </body> | |
| 60 </html> | |
| OLD | NEW |