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