将图像转换为HTML / CSS - 无法获得渐变

时间:2015-02-15 00:46:27

标签: html css

我一直试图在HTML / CSS中模仿这个图像而没有运气(不能让它看起来相似)。

enter image description here

我已尝试使用此网站http://www.colorzilla.com/gradient-editor/#_,但我无法获得输出以模仿它。

以下是对jsfiddle的尝试 - http://jsfiddle.net/rea2pkho/2/

以下是我目前的代码:

<div id="bar"></div>
#bar {
    width: 600px;
    height: 30px;
background: -moz-linear-gradient(top,  rgba(185,185,185,0.25) 0%, rgba(185,185,185,0.25) 96%, rgba(185,185,185,0.19) 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(185,185,185,0.25)), color-stop(96%,rgba(185,185,185,0.25)), color-stop(100%,rgba(185,185,185,0.19))); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top,  rgba(185,185,185,0.25) 0%,rgba(185,185,185,0.25) 96%,rgba(185,185,185,0.19) 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top,  rgba(185,185,185,0.25) 0%,rgba(185,185,185,0.25) 96%,rgba(185,185,185,0.19) 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top,  rgba(185,185,185,0.25) 0%,rgba(185,185,185,0.25) 96%,rgba(185,185,185,0.19) 100%); /* IE10+ */
background: linear-gradient(to bottom,  rgba(185,185,185,0.25) 0%,rgba(185,185,185,0.25) 96%,rgba(185,185,185,0.19) 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#40b9b9b9', endColorstr='#30b9b9b9',GradientType=0 ); /* IE6-9 */
}

非常感谢任何建议。

THX

2 个答案:

答案 0 :(得分:2)

我建议this site生成CSS渐变。你的代码似乎错过了中间停止。

background: rgba(181,181,181,1);
background: -moz-linear-gradient(top, rgba(181,181,181,1) 0%, rgba(255,255,255,1) 48%, rgba(184,184,184,1) 100%);
background: -webkit-gradient(left top, left bottom, color-stop(0%, rgba(181,181,181,1)), color-stop(48%, rgba(255,255,255,1)), color-stop(100%, rgba(184,184,184,1)));
background: -webkit-linear-gradient(top, rgba(181,181,181,1) 0%, rgba(255,255,255,1) 48%, rgba(184,184,184,1) 100%);
background: -o-linear-gradient(top, rgba(181,181,181,1) 0%, rgba(255,255,255,1) 48%, rgba(184,184,184,1) 100%);
background: -ms-linear-gradient(top, rgba(181,181,181,1) 0%, rgba(255,255,255,1) 48%, rgba(184,184,184,1) 100%);
background: linear-gradient(to bottom, rgba(181,181,181,1) 0%, rgba(255,255,255,1) 48%, rgba(184,184,184,1) 100%);
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#b5b5b5', endColorstr='#b8b8b8', GradientType=0 );

Fiddle

答案 1 :(得分:2)

尝试http://gradientfinder.com/您可以将图片拖入其中,它会为您创建css,或者如果有问题,您可以从头开始创建,如下所示:

height: 15px; background: -webkit-linear-gradient(bottom, rgb(159, 159,159) 0%, rgb(255, 255, 255) 60%, rgb(159, 159, 159) 100%);