display-contents-dynamic-before-after-001.html (930B)
1 <!DOCTYPE html> 2 <meta charset="utf-8"> 3 <title>CSS Display: Dynamic changes to ::before and ::after on display:contents</title> 4 <link rel="author" title="Emilio Cobos Álvarez" href="mailto:ecobos@igalia.com"> 5 <link rel="help" href="https://drafts.csswg.org/css-display-3/#valdef-display-contents"> 6 <link rel="match" href="display-contents-pass-green-no-red-ref.html"> 7 <style> 8 div { display: contents; color: green; } 9 .p::before { content: "P" } 10 .a::before { content: "A" } 11 .s::after { content: "S" } 12 div::before { color: red; display: contents; border: 1px solid red; } 13 .active div::before { color: green; } 14 </style> 15 <p>You should see the word PASS in green and no red below.</p> 16 <div><!-- 17 --><div><div class="p"></div></div><!-- 18 --><div></div><!-- 19 --><div class="a"></div><!-- 20 --><div>S<div class="s"></div></div> 21 </div> 22 <script> 23 document.body.offsetTop; 24 document.body.className = "active"; 25 </script>