1

I've created a gradient which goes from transparent to white using this CSS:

linear-gradient(to right, transparent, white)

Also see: http://jsfiddle.net/fs8gpha2/

This is all working fine in Chrome, but in both Safari and Firefox the center of the gradient is grey. Is there any way to work around this?

Thanks!

2 Answers 2

2

Try like this:

body {
    background: #000;
}

div {
    background: linear-gradient(to right, rgba(255, 255, 255, 0), rgb(255, 255, 255));
    width: 100%;
    height: 100px;
}

Here is the Demo

Sign up to request clarification or add additional context in comments.

1 Comment

I apparently had to wait for 5 minutes before I was allowed to accept an answer. Done now :)
2

This is would be a cross-browser solution (I updated the jsfiddle):

http://jsfiddle.net/fs8gpha2/4/

div { 
background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(rgba(255, 255, 255, 0)), to(rgba(255, 255, 255, 1)));
background: -webkit-linear-gradient(left, rgba(255, 255, 255, 0), rgba(255, 255, 255, 1));
background: -moz-linear-gradient(left, rgba(255, 255, 255, 0), rgba(255, 255, 255, 1));
background: -o-linear-gradient(left, rgba(255, 255, 255, 0), rgba(255, 255, 255, 1));
background: -ms-linear-gradient(left, rgba(255, 255, 255, 0), rgba(255, 255, 255, 1));
background: linear-gradient(left, rgba(255, 255, 255, 0), rgba(255, 255, 255, 1));
background-color: rgba(255, 255, 255, 0); width:100%; height:100px; }

Cheers

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.