0

In a help of you all. I am not new to CSS but new to this problem. I really wanted to use CSS gradient property. But the way I need is that I need to set the gradient from bottom to top and right to left. Simply like scroll bars, in page right and bottom. I have created bottom to top one class and right to left one class. Simpe CSS concept it overwrites with the latest style.

How can I tackle this situation. The way I tried is as below:

.bottom_to_top{background: -webkit-linear-gradient(center top, #FFFFFF 95%, #80868E 100%);}
.right_to_left{-webkit-linear-gradient(center left,#FFFFFF 95%, #80868E 100%);}

I have called these two classes but simply one is overwritten by another. How can I tackle this situation. No Browser compatibility (Only for Chrome). No need the image usage also.

2 Answers 2

2

To display both gradients you need a semi-trasparency on the top one.

Demo

CSS:

.bottom_to_top{
    background: -webkit-gradient(linear, center top, center bottom, color-stop(95%, #FFFFFF), color-stop(100%, #80868E));
    background: -webkit-linear-gradient(top, #FFFFFF 95%, #80868E 100%);
}
.right_to_left{
    background-image: -webkit-gradient(linear, left center, right center, color-stop(0%, rgba(255, 255, 255, 0.2)), color-stop(95%, rgba(255, 255, 255, 0.5)), color-stop(100%, #80868E));
    background-image: -webkit-linear-gradient(left, rgba(255, 255, 255, 0.2) 0%, rgba(255, 255, 255, 0.5) 95%, #80868E 100%);
}​

Notice that .right_to_left uses rgba instead of hex. Adjust it to your needings (you can use a simple online generator like visualcsstools).

Also, for complete Chrome support you need the double declaration (Chrome<10)


Using a single div, with multiple bgs:

Demo

.gradients{
    background:-webkit-gradient(linear, left center, right center, color-stop(0%, rgba(255, 255, 255, 0.2)), color-stop(95%, rgba(255, 255, 255, 0.5)), color-stop(100%, #80868E)), -webkit-gradient(linear, center top, center bottom, color-stop(95%, #FFFFFF), color-stop(100%, #80868E));
    background:-webkit-linear-gradient(left, rgba(255, 255, 255, 0.2) 0%, rgba(255, 255, 255, 0.5) 95%, #80868E 100%),  -webkit-linear-gradient(top, #FFFFFF 95%, #80868E 100%);
}

​ As you can see the first declaration in the one in front, while the second one is the background.

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

2 Comments

Hi.. this is really awesome.. working really fine.. May be stupid question I am going to ask.. is it difficult to apply both classes to only one div element? Do we really need to use two div elements??
thanks mate.. this is what I need.. really nice.. I almost spoiled more than 5 hours to find solutions.. :(... thanks to save my time mate..
1

Your problem is that your actually only using -webkit-linear-gradient(center left,#FFFFFF 95%, #80868E 100%); as you should use

-webkit-linear-gradient(center left,#FFFFFF 95%, #80868E 100%);
-o-linear-gradient(center left,#FFFFFF 95%, #80868E 100%);
-moz-linear-gradient(center left,#FFFFFF 95%, #80868E 100%);

IE is tricky with gradients, you must use filter

2 Comments

mate.. you better read the question properly... I need it only for Chrome and gradient should be right to left and bottom to top at same time for the particular element I called the class.. not in angle direction.. should be perpendicular to right border of the page and bottom border of the page.. did I confused in question??
@FaizulHasan sorry, I misunderstood you, I thought that you need it browser compatible.

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.