position-sticky-margins-002.html (1118B)
1 <!DOCTYPE html> 2 <meta charset="utf-8"> 3 <title>CSS Position Test: Test position:sticky element with auto margin in flex container</title> 4 <link rel="author" title="Ting-Yu Lin" href="mailto:tlin@mozilla.com"> 5 <link rel="author" title="Mozilla" href="https://www.mozilla.org/"> 6 <link rel="help" href="https://drafts.csswg.org/css-position/#staticpos-rect"> 7 <link rel="help" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1488080"> 8 <link rel="match" href="../../reference/ref-filled-green-100px-square.xht"> 9 <meta name="assert" content="This test verifies that a position:sticky element aligning with 'auto' margin still honors the sticky positioning."> 10 11 <style> 12 #container{ 13 width: 100px; 14 height: 100px; 15 overflow: hidden; 16 background: red; 17 } 18 .flex { 19 display: flex; 20 flex-direction: column; 21 height: 500px; 22 } 23 .child { 24 width: 100px; 25 height: 100px; 26 background: green; 27 position: sticky; 28 margin-top: auto; 29 bottom: 0; 30 } 31 </style> 32 33 <p>Test passes if there is a filled green square and <strong>no red</strong>.</p> 34 <div id="container"> 35 <div class="flex"> 36 <div class="child"></div> 37 </div> 38 </div>