flexbox-with-pseudo-elements-002.html (2523B)
1 <!DOCTYPE html> 2 <!-- 3 Any copyright is dedicated to the Public Domain. 4 http://creativecommons.org/publicdomain/zero/1.0/ 5 --> 6 <!-- Testcase to ensure we handle ::before and ::after pseudo-elements on 7 a flex container and treat them as flex items (e.g. honoring "order"). 8 --> 9 <html> 10 <head> 11 <title>CSS Test: Testing that generated content nodes are treated as a flex items, and honor 'order'</title> 12 <link rel="author" title="Daniel Holbert" href="mailto:dholbert@mozilla.com"> 13 <link rel="help" href="http://www.w3.org/TR/css-flexbox-1/#flex-items"> 14 <link rel="match" href="flexbox-with-pseudo-elements-002-ref.html"> 15 <meta charset="utf-8"> 16 <style> 17 .flexContainer { 18 display: flex; 19 margin-bottom: 2px; 20 background: lightgray; 21 } 22 .withBefore::before { 23 content: 'b'; 24 background: yellow; 25 /* This 'order' value should place us after the other elements, visually, 26 even though we're ::before. */ 27 order: 1; 28 } 29 .withAfter::after { 30 content: 'a'; 31 background: lightblue; 32 /* This 'order' value should place us before the other elements, visually, 33 even though we're ::after. */ 34 order: -1; 35 } 36 </style> 37 </head> 38 <body> 39 <!-- 'b' should be at end, due to its high 'order' value: --> 40 <div class="flexContainer withBefore"> 41 <div>I</div> 42 </div> 43 44 <!-- 'b' should be at beginning, since it's '::before' and the other item has 45 a matching 'order' value: --> 46 <div class="flexContainer withBefore"> 47 <div style="order: 1">I</div> 48 </div> 49 50 <!-- 'a' should be at beginning, due to its low 'order' value: --> 51 <div class="flexContainer withAfter"> 52 <div>I</div> 53 </div> 54 55 <!-- 'b' should be at beginning, since it's '::after' and the other item has 56 a matching 'order' value: --> 57 <div class="flexContainer withAfter"> 58 <div style="order: -1">I</div> 59 </div> 60 61 <!-- As above, the ::after 'a' should be at beginning, and the ::before 'b' 62 should be at end, due to their 'order' values --> 63 <div class="flexContainer withBefore withAfter"> 64 <div>I</div> 65 </div> 66 67 <!-- ...but now the normal item "I" has its order increased, so it'll go 68 at the end. --> 69 <div class="flexContainer withBefore withAfter"> 70 <div style="order: 1">I</div> 71 </div> 72 73 <!-- ...and now the normal item "I" has its order reduced, so it'll go 74 at the beginning. --> 75 <div class="flexContainer withBefore withAfter"> 76 <div style="order: -1">I</div> 77 </div> 78 </body> 79 </html>