我有適用於它下面的梯度一個div:如何通過JavaScript更改CSS漸變?
/* Mozilla Firefox */
background-image: -moz-linear-gradient(top, #2E2E28 0%, #4D4C48 100%);
/* Opera */
background-image: -o-linear-gradient(top, #2E2E28 0%, #4D4C48 100%);
/* Webkit (Safari/Chrome 10) */
background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0, #2E2E28), color-stop(1, #4D4C48));
/* Webkit (Chrome 11+) */
background-image: -webkit-linear-gradient(top, #2E2E28 0%, #4D4C48 100%);
/* IE10+ */
background: -ms-linear-gradient(top, #2E2E28 0%,#4D4C48 100%);
/* W3C */
background: linear-gradient(top, #2E2E28 0%,#4D4C48 100%);
我應該如何改變「#2E2E28」到另一個號碼,但還是避免了跨瀏覽器的噩夢?
不這項工作對你的http://stackoverflow.com/questions/11943322/setting-a-css-gradient-in-javascript – Piyuesh 2013-04-25 15:39:55
如果你很高興使用jQuery,它會使樣式標準化,所以你不需要包含所有的前綴。 – Spudley 2013-04-25 15:40:24
@Piyuesh在這個例子中沒有任何東西保留了跨瀏覽器的功能 – 2013-04-25 15:46:51