1

我使用以下 CSS 代码为线性渐变创建了一个线性渐变:

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);

在此处输入图像描述

我想知道如何获得相同的渐变,从 #444444 到 #222222,向上直到白色箭头,停止,然后从 #222222 开始以与上面相同的方式返回到 #444444 的底部边缘.

谢谢你。

4

3 回答 3

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 */
于 2012-08-09T17:16:15.780 回答
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 */

在这里可以找到一个很棒的学习工具。

于 2012-08-09T17:16:10.140 回答
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了解更多信息。

于 2012-08-09T17:17:37.593 回答