How to Create Gradient in CSS3

How to Create Gradient in CSS3

Safari 4+, Chrome 1+, Firefox 3.6+, and Opera 11.10+ are all now supporting CSS3 gradients. This wide browser support makes using them for progressive enhancement all the more appealing. More good news, CSS3 gradients fall into the camp where you can specify fallbacks (i.e. images) so that browsers that don’t support them just use the image instead.

But wait… if you need to use an image anyway, why bother with declaring the gradient with CSS? That is kind of how I felt for a long time, but there is one important aspect that makes it worth it: browsers that support them don’t load the image fallback. One less HTTP Request = all the faster your site will load.

How it’s done

Cutting to the chase, here is the CSS for the most simple possible top-to-bottom linear gradient:

.gradient-bg {
/* fallback/image non-cover color */
background-color: #1a82f7;

/* fallback image */
background-image: url(images/fallback-gradient.png);

/* Safari 4+, Chrome 1-9 */
background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#2F2727), to(#1a82f7));

/* Safari 5.1+, Mobile Safari, Chrome 10+ */
background-image: -webkit-linear-gradient(top, #2F2727, #1a82f7);

/* Firefox 3.6+ */
background-image: -moz-linear-gradient(top, #2F2727, #1a82f7);

/* IE 10+ */
background-image: -ms-linear-gradient(top, #2F2727, #1a82f7);

/* Opera 11.10+ */
background-image: -o-linear-gradient(top, #2F2727, #1a82f7);
}

You could add the non-prefixed version too, but since that’s not yet supported in anything I typically opt out of that, in case there are last minute changes to spec.

And once more with better formatting and without the comments:

.gradient-bg {
   background-color: #1a82f7; 
   background-image: url(images/fallback-gradient.png); 
   background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#2F2727), to(#1a82f7));
   background-image: -webkit-linear-gradient(top, #2F2727, #1a82f7); 
   background-image:    -moz-linear-gradient(top, #2F2727, #1a82f7);
   background-image:     -ms-linear-gradient(top, #2F2727, #1a82f7);
   background-image:      -o-linear-gradient(top, #2F2727, #1a82f7);
}

Demo

Obtain the most prominent n image wordpress plugin readily available today, you'll find both free and superior plugins right here. We have checked the whole web, assessed hundreds of suggested Wordpress plugins and decided on the most effective.
Discover breaking news the most up to date technology information, including new item releases, sales figures and tech industry performance details. Check out short articles on brand-new devices and prototypes for future modern technology.
best seo you should and need to not be doing on your Websites to make them rank higher in online search engine. In a constantly transforming Search Engine Optimization landscape, it is very important to continue to be updated about the transforming practices and approaches of optimization.
Here is a listing of tools blogging software from a central area. There are WordPress dashboards, along with multisite devices to take care of domains, motifs, campaigns, and a lot more. includes one-click gain access to, tracking, back-up, deployment, posting, and protection attributes. Review which of your websites have motifs and plugins that require focus. Along with one click, upgrade all your plugins, styles or core WordPress software application.


My Name is Adi Saputra. I come from Indonesia. I want to develop www.tuto-rial.com Blog Being the best, So much of it as a reference in the world of IT in particular programming

Comments are closed.