用圖片做漸變不靈活,Firefox 3.6+、Safari/Chrome 已支援原生漸變,但語法**不統一**。
-webkit-gradient(linear, 0 0, 0 100%, from(red), to(blue));

參數順序:類型、起點座標、終點座標、起始色、結束色。座標可用關鍵字(left top 等)。
-moz-linear-gradient(top, red, blue);

參數:起點方向(或角度 -45deg)、起始色、結束色。類型內建於屬性名。
不想 100% 全程漸變,只需細微區段:
background: white; /* 降級 */
background: -moz-linear-gradient(top, #dedede, white 8%);
background: -webkit-gradient(linear, 0 0, 0 8%, from(#dedede), to(white));
border-top: 1px solid white; /* 對比增強 */

/* Mozilla: 直接在顏色後加位置 */
background: -moz-linear-gradient(top, #dedede, white 8%, red 20%);
/* WebKit: 使用 color-stop(位置, 顏色) */
background: -webkit-gradient(linear, 0 0, 0 100%, from(#dedede), color-stop(8%, white), color-stop(20%, red));
WebKit 需顯式 color-stop,Mozilla 則直觀得多。
現代瀏覽器已統一支援標準語法:
background: linear-gradient(to bottom, red, blue); /* 向下 */
background: linear-gradient(45deg, red, blue); /* 角度 */
background: linear-gradient(to right, red 20%, orange 50%, yellow); /* 多色停駐 */
建議生產環境採用標準語法並配合 Autoprefixer 自動補前綴。