style-before-pseudo-ref.html (705B)
1 <!DOCTYPE html> 2 <html> 3 <link rel="stylesheet" type="text/css" href="/fonts/ahem.css" /> 4 <style> 5 div { 6 margin-left: 3px; 7 } 8 div::before { 9 width: 100px; 10 height: 100px; 11 margin-left: 2px; 12 content: 'foo'; 13 color: rgba(0, 0, 0, 0); 14 } 15 canvas{ 16 margin-left: 2px; 17 display: block; 18 position: relative; 19 top: -1em; 20 } 21 </style> 22 <body style="font: 10px/1 Ahem;"> 23 <div><canvas width="30px" height="10px"></canvas></div> 24 <script> 25 document.addEventListener('DOMContentLoaded', function() { 26 var canvas = document.querySelector('canvas'); 27 var context = canvas.getContext("2d"); 28 context.fillStyle = 'green'; 29 context.fillRect(0, 0, 30, 10); 30 }); 31 </script> 32 </body> 33 </html>