display-contents-dynamic-pseudo-insertion-001.html (781B)
1 <!doctype html> 2 <meta charset="utf-8"> 3 <title>CSS Test: Dynamic insertion on empty display: contents element with pseudo-elements</title> 4 <link rel="author" title="Emilio Cobos Álvarez" href="mailto:emilio@crisal.io"> 5 <link rel="help" href="https://drafts.csswg.org/css-display-3/#valdef-display-contents"> 6 <link rel=match href="display-contents-dynamic-pseudo-insertion-001-ref.html"> 7 <style> 8 .contents { 9 display: contents; 10 border: 10px solid red; 11 } 12 .contents::before { 13 content: "A"; 14 } 15 .contents::after { 16 content: "SS"; 17 } 18 </style> 19 <div class="contents"></div> 20 <script> 21 document.body.offsetTop; 22 let span = document.createElement('span'); 23 span.innerHTML = "P"; 24 let contents = document.querySelector('.contents'); 25 contents.parentNode.insertBefore(span, contents); 26 </script>