Note: This was made for conference talks displayed locally in Firefox 4, so it naturally looks/works better there. Use the arrow keys to navigate. Screenshots of how it was used here.
By Lea Verou (@LeaVerou)
Shapes of incrementally closer colors next to each other, creating the illusion of a smooth transition
background: url(gradient.png) repeat-x;
background: linear-gradient(#000, #fff);
Images with no intrinsic dimensions
background-image
border-image
list-style-image
cursor
content
* in theory
left = 0deg
bottom left
bottom = 90deg
bottom right
right = 180deg
top right
top = 270deg
top left
transparent = rgba(0,0,0,0) = transparent black
radial-gradient(25% 30%
,
farthest-side
,
gray
,
black
)
circle
or ellipse
closest-side
or contain
closest-corner
farthest-side
farthest-corner
or cover
background: -webkit-gradient( linear, 0 0, left bottom, from(black), color-stop(.6, hsl(180,50%,35%)), to(#b0a089) );
Tab Atkins Jr drafts a proposal with a much better syntax
—vs—
background: gradient(linear, 0 0, left bottom, from(black), color-stop(.6, hsl(180,50%,35%)), to(#b0a089));
(-moz- and -webkit- prefixes omitted for fairer comparison)
So currently, all browsers support them!
Conical gradients sound good, so I'll keep them in mind when I draft Image Values 4.Tab Atkins
-moz-
Firefox 3.6+-webkit-
Chrome & Webkit nightlies-o-
Opera 11.10 (linear only)-ms-
Internet Explorer 10-webkit-gradient()
on older Webkit browsersIE < 10 supports a few basic cases through filters:
filter: progid:DXImageTransform.Microsoft.gradient( GradientType=0, startColorstr='#81a8cb', endColorstr='#4477a1' );
Opera 9.5+, Firefox 4, Safari 5+, Chrome 7+, IE9
<svg xmlns="http://www.w3.org/2000/svg"> <defs> <linearGradient id="gradient" y2="100%"> <stop stop-color="silver" /> <stop stop-color="black" offset="100%" /> </linearGradient> </defs> <rect width="100%" height="100%" fill="url(#gradient)"></rect> </svg>
background: #5A5A5A url(gradient.svg); background-image: -moz-linear-gradient(top left, silver, black); background-image: -ms-linear-gradient(top left, silver, black); background-image: -o-linear-gradient(top left, silver, black); background-image: -webkit-gradient(linear, 0 0, 100% 100%, from(silver), to(black)); background-image: -webkit-linear-gradient(top left, silver, black); background-image: linear-gradient(top left, silver, black);