線性漸層函數不允許非標準方向
不允許線性漸層函數使用非標準方向值。
.foo { background: linear-gradient(to top, #fff, #000); }
/** ↑
* This (optional) first argument is the "direction" */
有效且標準的方向值包括下列其中一項
- 角度
to
加上側邊或角落 (to top
、to bottom
、to left
、to right
;to top right
、to right top
、to bottom left
等)
一個常見的錯誤 (符合過時的非標準語法) 是僅使用側邊或角落,而沒有加上前面的 to
。
選項
true
下列模式被視為問題
.foo { background: linear-gradient(top, #fff, #000); }
.foo { background: linear-gradient(bottom, #fff, #000); }
.foo { background: linear-gradient(left, #fff, #000); }
.foo { background: linear-gradient(45, #fff, #000); }
.foo { background: linear-gradient(to top top, #fff, #000); }
下列模式不會被視為問題
.foo { background: linear-gradient(to top, #fff, #000); }
.foo { background: linear-gradient(to bottom right, #fff, #000); }
.foo { background: linear-gradient(45deg, #fff, #000); }
.foo { background: linear-gradient(1.57rad, #fff, #000); }
/* Direction defaults to "to bottom" */
.foo { background: linear-gradient(#fff, #000); }