contain-content-011.html (2047B)
1 <!DOCTYPE html> 2 3 <meta charset="UTF-8"> 4 5 <title>CSS Containment Test: 'contain: content' does not turn on style containment</title> 6 7 <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/"> 8 <link rel="help" href="https://drafts.csswg.org/css-contain/#contain-property"> 9 <link rel="match" href="reference/contain-content-011-ref.html"> 10 11 <meta name="assert" content="'contain: content' turns on style containment. So, in this test, the counter of div.abspos child should not be reset and must not be reset."> 12 13 <style> 14 body 15 { 16 counter-reset: counter-of-abspos-div 17; 17 } 18 19 /* 20 This creates a new counter identified as 21 "counter-of-abspos-div" and initially sets 22 such counter to 17 (an entirely arbitrary 23 number) 24 */ 25 26 div 27 { 28 width: 100px; 29 } 30 31 32 div#contain-content 33 { 34 background-color: red; 35 contain: content; 36 height: 100px; 37 } 38 39 div.abspos 40 { 41 background-color: green; 42 height: 50px; 43 position: absolute; 44 right: 0; 45 } 46 47 div#contain-content > div.abspos 48 { 49 counter-increment: counter-of-abspos-div 4; 50 } 51 52 /* 53 This increments the counter identified as 54 "counter-of-abspos-div" of the step value 55 of 4 (an entirely arbitrary number) each and 56 every time there is a div.abspos child 57 within the subtree of div#contain-content 58 */ 59 60 div#first-abspos 61 { 62 top: 0px; 63 } 64 65 div#second-abspos 66 { 67 bottom: 0px; 68 } 69 70 div#result::after 71 { 72 content: counter(counter-of-abspos-div); 73 font-size: 3em; 74 } 75 76 /* 77 Now, the generated content is set to the 78 current value of the counter identified 79 as "counter-of-abspos-div": 80 17 + 4 * 2 == 25 81 */ 82 </style> 83 84 <body> 85 86 <p>Test passes if there is a filled green square, no red and the number 17. 87 88 <div id="contain-content"> 89 <div id="first-abspos" class="abspos"></div> 90 <div id="second-abspos" class="abspos"></div> 91 </div> 92 93 <div id="result"></div>