flexbox-position-fixed-2-ref.xhtml (2198B)
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 <!-- Reference case for fixed-position children of a flex container. --> 7 <html xmlns="http://www.w3.org/1999/xhtml"> 8 <head> 9 <style> 10 div.containingBlock { 11 top: 15px; 12 left: 20px; 13 height: 400px; 14 position: absolute; 15 border: 2px dashed purple; 16 } 17 .fixedpos { 18 position: absolute; 19 border: 2px dotted black; 20 } 21 div.flexbox { 22 width: 200px; 23 height: 100px; 24 } 25 div.a { 26 width: 100%; 27 height: 100px; 28 background: lightgreen; 29 display: inline-block; 30 } 31 div.b { 32 width: 100%; 33 height: 100px; 34 background: yellow; 35 display: inline-block; 36 } 37 div.inflex { 38 width: 20px; 39 height: 100px; 40 background: gray; 41 display: inline-block; 42 } 43 div.noFlexFn { 44 width: 16px; 45 height: 16px; 46 background: teal; 47 display: inline-block; 48 } 49 </style> 50 </head> 51 <body> 52 <div class="containingBlock"> 53 <!-- First child fixedpos: --> 54 <div class="flexbox" 55 ><div class="a fixedpos" style="width: 30px"/><div class="b"/></div> 56 <!-- Second child fixedpos: --> 57 <div class="flexbox" 58 ><div class="a"/><div class="b fixedpos" 59 style="width: 20px; left: 0"/></div> 60 <!-- Middle child fixedpos: --> 61 <div class="flexbox" 62 ><div class="a" style="width: 80px" 63 /><div class="inflex fixedpos" style="left: 0" 64 /><div class="b" style="width: 120px"/></div> 65 <!-- Third child fixedpos, w/ inflexible items & justify-content: space-around: --> 66 <div class="flexbox" 67 ><div class="inflex" style="margin-left: 15px" 68 /><div class="inflex" style="margin-left: 30px" 69 /><div class="inflex" style="margin-left: 30px" 70 /><div class="noFlexFn fixedpos" style="left: 90px" 71 /><div class="inflex" style="margin-left: 30px"/></div> 72 </div> 73 </body> 74 </html>