OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 | 2 |
3 <html> | 3 <html> |
4 <head> | 4 <head> |
5 <style> | 5 <style> |
6 body { | 6 body { |
7 margin: 0; | 7 margin: 0; |
8 width: 2000px; | 8 width: 2000px; |
9 overflow: hidden; /* hide scrollbars */ | 9 overflow: hidden; /* hide scrollbars */ |
10 } | 10 } |
11 | 11 |
| 12 p { |
| 13 position: relative; |
| 14 left: 100px; |
| 15 } |
| 16 |
12 .group { | 17 .group { |
13 position: relative; | 18 position: relative; |
14 width: 500px; | 19 width: 500px; |
15 height: 200px; | 20 height: 200px; |
16 } | 21 } |
17 | 22 |
18 .container { | 23 .flex-container { |
19 width: 400px; | 24 position: relative; |
| 25 display: flex; |
| 26 width: 200px; |
20 height: 180px; | 27 height: 180px; |
| 28 flex-flow: row wrap; |
21 outline: 2px solid black; | 29 outline: 2px solid black; |
22 } | 30 } |
23 | 31 |
24 .box { | 32 .box { |
25 width: 200px; | 33 width: 100px; |
26 height: 180px; | 34 height: 180px; |
27 } | 35 } |
28 | 36 |
| 37 .flex-item { |
| 38 width: 100px; |
| 39 height: 180px; |
| 40 display: flex; |
| 41 } |
| 42 |
29 .sticky { | 43 .sticky { |
30 position: sticky; | 44 position: sticky; |
31 left: 100px; | 45 left: 100px; |
32 background-color: green; | 46 background-color: green; |
33 } | 47 } |
34 | 48 |
35 .indicator { | 49 .indicator { |
36 position: absolute; | 50 position: absolute; |
37 top: 0; | 51 top: 0; |
38 left: 0; | 52 left: 0; |
39 background-color: red; | 53 background-color: red; |
40 } | 54 } |
41 </style> | 55 </style> |
42 <script> | 56 <script> |
43 function doTest() | 57 function doTest() |
44 { | 58 { |
45 window.scrollTo(100, 0); | 59 window.scrollTo(100, 0); |
46 } | 60 } |
47 window.addEventListener('load', doTest, false); | 61 window.addEventListener('load', doTest, false); |
48 </script> | 62 </script> |
49 </head> | 63 </head> |
50 <body> | 64 <body> |
51 <div class="group"> | 65 <p>This test checks the behavior of position:sticky with flex box items. |
52 <div class="indicator box" style="left: 200px;"></div> | 66 There should be no red.</p> |
53 <div class="container"> | 67 |
54 <div class="sticky box"></div> | 68 <div class="group" style="left: 100px"> |
| 69 <div class="indicator box" style="left: 100px;"></div> |
| 70 <div class="flex-container" style="left: 0px;"> |
| 71 <div class="sticky flex-item"></div> |
| 72 <div class="flex-item" style="background-color: green;"></div> |
55 </div> | 73 </div> |
56 </div> | 74 </div> |
57 | 75 |
58 <div class="group" style="left: 100px"> | 76 <div class="group" style="left: 150px"> |
59 <div class="indicator box" style="left: 100px;"></div> | 77 <div class="indicator box" style="left: 50px;"></div> |
60 <div class="container"> | 78 <div class="flex-container" style="left: 0px;"> |
61 <div class="sticky box"></div> | 79 <div class="sticky flex-item"></div> |
| 80 <div class="flex-item" style="background-color: green;"></div> |
62 </div> | 81 </div> |
63 </div> | 82 </div> |
64 | 83 |
65 <div class="group" style="left: 200px"> | 84 <div class="group" style="left: 200px"> |
66 <div class="indicator box" style="left: 0;"></div> | 85 <div class="indicator box" style="left: 0;"></div> |
67 <div class="container"> | 86 <div class="flex-container" style="left: 0px;"> |
68 <div class="sticky box"></div> | 87 <div class="sticky flex-item"></div> |
| 88 <div class="flex-item" style="background-color: green;"></div> |
69 </div> | 89 </div> |
70 </div> | 90 </div> |
| 91 |
71 </body> | 92 </body> |
72 </html> | 93 </html> |
OLD | NEW |