2012-08-09 73 views
1

我創建了一個線性漸變與下面的CSS代碼爲線性漸變:CSS線性漸變X到Y,則Y回X

background-color: #2c2c2c; 
background-image: -moz-linear-gradient(top, #444444, #222222); 
background-image: -ms-linear-gradient(top, #444444, #222222); 
background-image: -webkit-gradient(linear, 0 0, 0 0, from(#444444), to(#222222)); 
background-image: -webkit-linear-gradient(top, #444444, #222222); 
background-image: -o-linear-gradient(top, #444444, #222222); 
background-image: linear-gradient(top, #444444, #222222); 
background-repeat: repeat-x; 
filter: progid:dximagetransform.microsoft.gradient(startColorstr='#444444', endColorstr='#222222', GradientType=0); 

enter image description here

我不知道我怎樣才能得到從#444444到#222222的相同梯度直到白色箭頭停止,然後以與上述相同的方式從#222222開始並返回到#444444的底部邊緣。

謝謝。

回答

2
background: #000000; /* Old browsers */ 
background: -moz-linear-gradient(top, #000000 0%, #ff3033 50%, #000000 100%); /* FF3.6+ */ 
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#000000), color-stop(50%,#ff3033), color-stop(100%,#000000)); /* Chrome,Safari4+ */ 
background: -webkit-linear-gradient(top, #000000 0%,#ff3033 50%,#000000 100%); /* Chrome10+,Safari5.1+ */ 
background: -o-linear-gradient(top, #000000 0%,#ff3033 50%,#000000 100%); /* Opera 11.10+ */ 
background: -ms-linear-gradient(top, #000000 0%,#ff3033 50%,#000000 100%); /* IE10+ */ 
background: linear-gradient(to bottom, #000000 0%,#ff3033 50%,#000000 100%); /* W3C */ 
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#000000', endColorstr='#000000',GradientType=0); /* IE6-9 */ 
+0

非常感謝Edward! – Elias7 2012-08-09 17:40:55

+0

@ GirlCanCode2永遠受歡迎! – 2012-08-09 17:41:23

1

你應該能夠做這樣的事情:

background: #444444; /* Old browsers */ 
background: -moz-linear-gradient(top, #444444 0%, #222222 50%, #444444 100%); /* FF3.6+ */ 
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#444444), color- stop(50%,#222222), color-stop(100%,#444444)); /* Chrome,Safari4+ */ 
background: -webkit-linear-gradient(top, #444444 0%,#222222 50%,#444444 100%); /* Chrome10+,Safari5.1+ */ 
background: -o-linear-gradient(top, #444444 0%,#222222 50%,#444444 100%); /* Opera 11.10+ */ 
background: -ms-linear-gradient(top, #444444 0%,#222222 50%,#444444 100%); /* IE10+ */ 
background: linear-gradient(to bottom, #444444 0%,#222222 50%,#444444 100%); /* W3C */ 
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#444444', endColorstr='#444444',GradientType=0); /* IE6-9 */ 

一個很好的學習工具,可以發現here

+0

非常感謝Luke! – Elias7 2012-08-09 17:40:09

1

您需要指定顏色停止的地方看到50%的部分。

background: #444444; /* Old browsers */ 
background: -moz-linear-gradient(top, #444444 0%, #222222 50%, #444444 100%); /* FF3.6+ */ 
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#444444), color-stop(50%,#222222), color-stop(100%,#444444)); /* Chrome,Safari4+ */ 
background: -webkit-linear-gradient(top, #444444 0%,#222222 50%,#444444 100%); /* Chrome10+,Safari5.1+ */ 
background: -o-linear-gradient(top, #444444 0%,#222222 50%,#444444 100%); /* Opera 11.10+ */ 
background: -ms-linear-gradient(top, #444444 0%,#222222 50%,#444444 100%); /* IE10+ */ 
background: linear-gradient(to bottom, #444444 0%,#222222 50%,#444444 100%); /* W3C */ 
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#444444', endColorstr='#444444',GradientType=0); /* IE6-9 */ 

退房Ultimate CSS Gradient Generator獲取更多信息。

+0

非常感謝PHJ! – Elias7 2012-08-09 17:40:37

相關問題