1. 程式人生 > >CSS3 線性漸變

CSS3 線性漸變

background: linear-gradient(direction, color-stop1, color-stop2, ...);

從上到下:

#grad {
  background: -webkit-linear-gradient(red, blue); /* Safari 5.1 - 6.0 */
  background: -o-linear-gradient(red, blue); /* Opera 11.1 - 12.0 */
  background: -moz-linear-gradient(red, blue); /* Firefox 3.6 - 15 */
  background
: linear-gradient(red, blue); /* 標準的語法 */ }

從左到右:

#grad {
  background: -webkit-linear-gradient(left, red , blue); /* Safari 5.1 - 6.0 */
  background: -o-linear-gradient(right, red, blue); /* Opera 11.1 - 12.0 */
  background: -moz-linear-gradient(right, red, blue); /* Firefox 3.6 - 15 */
  background
: linear-gradient(to right, red , blue); /* 標準的語法 */ }