Adam
Adam

Reputation: 20882

Convert an image into HTML/CSS - Can't get gradient right

I've been trying to mimic this image in HTML/CSS with no luck (can't get it to look similar).

enter image description here

I've tried working with this site http://www.colorzilla.com/gradient-editor/#_ but I can't get the output to mimic it.

Here is an attempt on jsfiddle - http://jsfiddle.net/rea2pkho/2/

Here is the code I currently have:

<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 */
}

What can I try next?

Upvotes: 0

Views: 109

Answers (2)

David Munday
David Munday

Reputation: 19

Try http://gradientfinder.com/ you can drag the image into it and it will create the css for you, or if theres an issue try you can create it from scratch like below:

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

Upvotes: 2

meadowstream
meadowstream

Reputation: 4132

I'd recommend this site to generate CSS gradients. Your code seem to be missing the middle stop somehow.

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

Upvotes: 2

Related Questions