Is there a way to create a color gradient in CSS without using an image file?
I am trying to give a DIV a background with a color gradient so that it looks glossy.
Is there a way to create a color gradient in CSS without using an image file?
I am trying to give a DIV a background with a color gradient so that it looks glossy.
No this is not possible you just can set plain color in CSS. The only way to do is to create an image an set it as background.
#yourdiv {
background: transparent url(yourimg.png) 0 0 scroll no-repeat;
}
EDIT: like said in the other answers it is possible in some browsers. But when speaking of possible I like to reefer to most the browsers.
Safari (Webkit) supports it: http://webkit.org/blog/175/introducing-css-gradients/
Firefox 3.6+ supports it: https://developer.mozilla.org/en/CSS/-moz-linear-gradient
W3 spec defines support for it: http://dev.w3.org/csswg/css3-images/#gradients-
And you can use Modernizr to detect support and fall back on an image: http://www.modernizr.com/docs/#cssgradients
Webkit browsers support pure-CSS gradients like this (see this example in Safari or Chrome) - but practically speaking for a cross-browser implementation you'll need to use images.
Try this if you are using or can use PHP
http://snipplr.com/view/26070/multicolor-gradient-generator/
http://www.designdetector.com/2005/09/css-gradients-demo.php
See javascript solutions here
http://stackoverflow.com/questions/1472422/jquery-gradient-plugin
http://www.bennadel.com/blog/1014-Creating-Transparent-Gradients-With-jQuery.htm
Some gradient image generator
http://www.grsites.com/generate/group/4000/
http://tools.dynamicdrive.com/gradient/
http://www.allcrunchy.com/Web_Stuff/Gradient_Generator/
71 Gradient Resources for Web Design