Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

White to transparent gradient with background image

Tags:

css

gradient

I need to apply a white to transparent gradient which covers about a 1/4 of the top of the page and a background image visible for the rest of the page.

Im looking to achieve a seamless blend from a gradient to a textured image and to do this in CSS3.

like image 742
Craig Avatar asked Jun 18 '11 17:06

Craig


People also ask

Can I use linear gradient with background image?

CSS gradients allow us to display smooth transitions between two or more colours. They can be added on top of the background image by simply combining the background-image URL and gradient properties.


2 Answers

I prefer to use another tool for gradients generation - EnjoyCSS. It also allows to generate other CSS features like background, shadows, transitions etc.

enter image description here White to transparent gradient generated with this tool:

background-image: -webkit-linear-gradient(-90deg, rgba(255,255,255,0) 0, rgba(255,255,255,1) 100%);
background-image: -moz-linear-gradient(180deg, rgba(255,255,255,0) 0, rgba(255,255,255,1) 100%);
background-image: linear-gradient(180deg, rgba(255,255,255,0) 0, rgba(255,255,255,1) 100%);
background-position: 50% 50%;
-webkit-background-origin: padding-box;
background-origin: padding-box;
-webkit-background-clip: border-box;
background-clip: border-box;
-webkit-background-size: auto auto;
background-size: auto auto;
like image 39
Mikhail Shabrikov Avatar answered Oct 20 '22 14:10

Mikhail Shabrikov


I recommend Ultimate CSS Gradient Generator - ColorZilla.com

It's a well designed tool and there's a white to transparent preset.

css gradient generator

The CSS code that it generates for a white to transparent gradient is this:

background: -moz-linear-gradient(top, rgba(255,255,255,1) 0%, rgba(255,255,255,0) 100%); /* FF3.6-15 */
background: -webkit-linear-gradient(top, rgba(255,255,255,1) 0%,rgba(255,255,255,0) 100%); /* Chrome10-25,Safari5.1-6 */
background: linear-gradient(to bottom, rgba(255,255,255,1) 0%,rgba(255,255,255,0) 100%); /* W3C, IE10+, FF16+, Chrome26+, Opera12+, Safari7+ */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#ffffff', endColorstr='#00ffffff',GradientType=0 ); /* IE6-9 */
like image 149
MikeM Avatar answered Oct 20 '22 13:10

MikeM