Hay una alternativa para hacer gradientes en navegadores estandar, sin usar imágenes, usando canvas. He aquí un ejemplo crossbrowser:
Código PHP:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Gradientes</title>
<style>
#v,#h{ width:200px;height:100px; border:1px solid #000;}
</style>
<script>
function $(x){return document.getElementById(x);}
function css(id,prop){
if(window.getComputedStyle){
return document.defaultView.getComputedStyle($(id),null).getPropertyValue(prop);
}else{
var re = /(-([a-z]){1})/g;
if (prop == 'float') prop = 'styleFloat';
if (re.test(prop)) {
prop = prop.replace(re, function () {
return arguments[2].toUpperCase();
});
}
return $(id).currentStyle[prop] ? $(id).currentStyle[prop] : null;
}
}
function gradiente(idObj,col1,col2,tipo){
if (document.createElement("canvas").getContext) {
/* ---- canvas ---- */
var b1=parseInt(col1.substr(5,2),16);
var g1=parseInt(col1.substr(3,2),16);
var r1=parseInt(col1.substr(1,2),16);
var b2=parseInt(col2.substr(5,2),16);
var g2=parseInt(col2.substr(3,2),16);
var r2=parseInt(col2.substr(1,2),16);
ref = document.createElement("canvas");
ref.width = parseInt(css(idObj,'width'));
ref.height =parseInt(css(idObj,'height'))
var context = ref.getContext("2d");
context.translate(0,0);
context.scale(1,1);
if(tipo){
context.translate(ref.width,0);
context.rotate(Math.PI/2);
var gradient = context.createLinearGradient(0, 0, 0, ref.width);
gradient.addColorStop(1, "rgba("+r1+","+g1+","+ b1+", 1.0)");
gradient.addColorStop(0, "rgba("+r2+","+g2+","+ b2+", 1.0)");
context.fillStyle = gradient;
context.fillRect(0,0,ref.height, ref.width);
}else{
var gradient = context.createLinearGradient(0, 0, 0, ref.height);
gradient.addColorStop(0, "rgba("+r1+","+g1+","+ b1+", 1.0)");
gradient.addColorStop(1, "rgba("+r2+","+g2+","+ b2+", 1.0)");
context.fillStyle = gradient;
context.fillRect(0,0,ref.width, ref.height);
}
$(idObj).appendChild(ref);
} else {
/* ---- DXImageTransform ---- */
$(idObj).style.filter=
"progid:DXImageTransform.Microsoft.Gradient(startColorstr="+col1+", endColorstr="+col2+", GradientType="+tipo+")"
}
}
window.onload=function(){
gradiente('v','#FF0000','#CCCCCC',0);
gradiente('h','#FF0000','#CCCCCC',1);
}
</script>
</head>
<body>
<div id="v"></div>
<div id="h"></div>
</body>
</html>