2016-08-15 64 views
0

所以這裏就是我想:您可以用線性梯度財產做垂直背景顏色

body { 
    height:100%; 
    background: -moz-linear-gradient(left, #DB2B39 50%, #2B303A 50%); 
    background: -webkit-linear-gradient(left, #DB2B39 50%,#2B303A 50%); 
    background: linear-gradient(to right, #DB2B39 50%,#2B303A 50%); 
} 

Vertical colors

但那是隻生產一個水平分割,這似乎有些奇怪喲如果沒有條紋,就不能輕易做到。

我是否錯過了一些非常明顯的東西?

+0

http://www.colorzilla.com/gradient-editor/ –

回答

0

這是製作水平漸變,因爲您將angle設置爲「向右」。如果你改爲to bottomtop它會產生一個垂直梯度。

body { 
    height:100%; 
    background: -moz-linear-gradient(top, #DB2B39 50%, #2B303A 50%); 
    background: -webkit-linear-gradient(top, #DB2B39 50%,#2B303A 50%); 
    background: linear-gradient(to bottom, #DB2B39 50%,#2B303A 50%); 
} 

請檢查線性梯度here的所有值。

0

你只需要添加值「fixed」。見下文。

body { 
background: linear-gradient(to bottom, rgba(219,43,57,1) 50%,rgba(43,48,58,1) 50%,rgba(10,8,9,1) 50%) fixed; 
} 

http://codepen.io/adamfollett/pen/YWBmxR

+0

謝謝你,這是完美的:d –