How CSS makes the background color gradient compatible

Source: Internet
Author: User
Recently in the project, a lot of places have used linear gradient, such as: Form Submit button background, data display title background, etc., according to the previous practice is to cut 1px pictures and then repeat-x. I'll show you how to do this with CSS.

Css3:linear-gradient

For example: black gradient to white, the code is as follows:


. gradient{    Background:-moz-linear-gradient (top, #000000 0, #ffffff 100%);    Background:-webkit-gradient (linear, left top, left bottom, Color-stop (0%, #000000), Color-stop (100%, #ffffff));    Background:-webkit-linear-gradient (top, #000000 0, #ffffff 100%);    Background:-o-linear-gradient (top, #000000 0, #ffffff 100%);    Background:-ms-linear-gradient (top, #000000 0, #ffffff 100%);    Background:linear-gradient (to bottom, #000000 0, #ffffff 100%);}

Description:linear-gradient Specific usage point this entry .

IE Filter: Filter

Linear-gradient below IE9 is not supported, so for IE6-IE8 we can use filters to solve, the code is as follows:


. gradient{    filter:progid:DXImageTransform.Microsoft.gradient (startcolorstr= ' #000000 ', endcolorstr= ' #ffffff ' , gradienttype=0);}

Because filter is the private property of IE, we need to handle the filter effect separately for IE9, the code is as follows:


: root {filter:none;}

Summarize:

In summary, the compatibility of linear gradients is as follows:


.gradient{background: #000000;    Background:-moz-linear-gradient (top, #000000 0, #ffffff 100%);    Background:-webkit-gradient (linear, left top, left bottom, Color-stop (0%, #000000), Color-stop (100%, #ffffff));    Background:-webkit-linear-gradient (top, #000000 0, #ffffff 100%);    Background:-o-linear-gradient (top, #000000 0, #ffffff 100%);    Background:-ms-linear-gradient (top, #000000 0, #ffffff 100%);    Background:linear-gradient (to bottom, #000000 0, #ffffff 100%); Filter:progid:DXImageTransform.Microsoft.gradient (startcolorstr= ' #000000 ', endcolorstr= ' #ffffff ', gradienttype=0 );}:root. Gradient{filter:none;} 
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.