So I figured I'd try and recreate this image in just CSS.. I have it perfected in Chrome and Internet Explorer 9 but issues in Firefox, anyone got any ideas on a fix? <div style="width:100px; margin-left:100px; height:200px;background:#FF0000; overflow:hidden;"> <div style="height:50px; background:#000; box-shadow:0px 0px 150px 70px #000;"></div> </div> Code (markup):
Yeah, you need to use the mozilla extension to make it work in Firefox, and you should also add the webkit extension. https://developer.mozilla.org/En/CSS/Box-shadow But it still doesn't work in IE8/7/6. No surprise! <html> <head> <style type="text/css"> #container { background:#FF0000; height:200px; margin-left:100px; overflow:hidden; width:100px; } #box { background:#000; box-shadow: 0px 0px 150px 70px #000; -moz-box-shadow: 0px 0px 150px 70px #000; -webkit-box-shadow: 0px 0px 150px 70px #000; height:50px; } </style> </head> <body> <div id="container"> <div id="box"></div> </div> </body> </html> HTML:
Yeah, box-shadow is inconsistent across the browsers. Canvas gradient seems to work better, but it still doesn't work in IE8/7/6. <!DOCTYPE html> <html> <head> <title>Canvas Gradient Demo</title> <script type="text/javascript"> function drawBox() { var context = document.getElementById("canvas").getContext("2d"); var gradient = context.createLinearGradient(0, 0, 0, 200); gradient.addColorStop(0, "black"); gradient.addColorStop(1, "red"); context.fillStyle = gradient; context.fillRect(0, 0, 100, 200); } </script> </head> <body onload="drawBox()"> <canvas id="canvas" width="100" height="200"></canvas> </body> </html> HTML: