flexbox-margin-auto-horiz-002.xhtml (2623B)
1 <?xml version="1.0" encoding="UTF-8"?> 2 <!-- 3 Any copyright is dedicated to the Public Domain. 4 http://creativecommons.org/publicdomain/zero/1.0/ 5 --> 6 <!-- Testcase with a variety of 'display: flex' examples 7 with margin-top and/or margin-bottom set to 'auto' on flex items. --> 8 <html xmlns="http://www.w3.org/1999/xhtml"> 9 <head> 10 <title>CSS Test: Testing vertical auto margins on flex items in a horizontal flex container</title> 11 <link rel="author" title="Daniel Holbert" href="mailto:dholbert@mozilla.com"/> 12 <link rel="help" href="http://www.w3.org/TR/css-flexbox-1/#auto-margins"/> 13 <link rel="match" href="flexbox-margin-auto-horiz-002-ref.xhtml"/> 14 <style> 15 div.flexbox { 16 border: 2px dotted black; 17 display: flex; 18 margin-bottom: 2px; 19 width: 100px; 20 } 21 div.fixedSize { 22 width: 20px; 23 height: 20px; 24 } 25 div.gray { background: gray; } 26 div.green { background: green; } 27 div.pink { background: pink; } 28 div.blue { background: blue; } 29 30 div.autoTop { margin-top: auto; } 31 div.autoBottom { margin-bottom: auto; } 32 div.fixedTop { margin-top: 10px; } 33 div.fixedBottom { margin-bottom: 10px; } 34 </style> 35 </head> 36 <body> 37 38 <!-- fixed-height flexbox, with items that have auto margins --> 39 <div class="flexbox" style="height: 100px"> 40 <div class="fixedSize green autoTop"/> 41 <div class="fixedSize pink autoBottom"/> 42 <div class="fixedSize blue autoTop autoBottom"/> 43 </div> 44 <!-- fixed-height flexbox, with items that have auto & fixed margins --> 45 <div class="flexbox" style="height: 100px"> 46 <div class="fixedSize green autoTop fixedBottom"/> 47 <div class="fixedSize pink autoBottom fixedTop"/> 48 </div> 49 50 <!-- height-shrinkwrapping flexbox, sized by item w/ fixed height & margins, 51 with other items that have auto margins --> 52 <div class="flexbox"> 53 <div class="fixedSize green autoTop"/> 54 <div class="fixedSize pink autoBottom"/> 55 <div class="fixedSize blue autoTop autoBottom"/> 56 <div class="fixedTop fixedBottom gray" style="width: 10px; height: 30px"/> 57 </div> 58 59 <!-- height-shrinkwrapping flexbox, sized by item w/ fixed height & margins, 60 with other items that have auto & fixed margins --> 61 <div class="flexbox"> 62 <div class="fixedSize green autoTop fixedBottom"/> 63 <div class="fixedSize pink autoBottom fixedTop"/> 64 <div class="fixedTop fixedBottom gray" style="width: 10px; height: 30px"/> 65 </div> 66 67 </body> 68 </html>