CSS3 Fade __ Gradient

Source: Internet
Author: User

CSS3 defines two types of gradients (gradients)://gradients must consist of more than 2 colors for linear gradients (Linear gradients)-downward/up/left/right/diagonal radial gradients (radial gradients)-defined by their center

Linear gradient-from top to bottom (by default)

The following example shows a linear gradient that starts at the top. Starting point is red, slowly transition to blue: instance

Linear gradient from top to bottom: #grad {
Background:-webkit-linear-gradient (red, blue); * Safari 5.1-6.0 * *
Background:-o-linear-gradient (red, blue); * Opera 11.1-12.0 * *
Background:-moz-linear-gradient (red, blue); * * Firefox 3.6-15 * *
Background:linear-gradient (red, blue); /* STANDARD Syntax * *
}



Linear gradient-left to right

The following example shows a linear gradient starting from the left. Starting point is red, slowly transition to blue: instance

Linear gradient from left to right: #grad {
Background:-webkit-linear-gradient (left, red, blue); * Safari 5.1-6.0 * *
Background:-o-linear-gradient (right, red, blue); * Opera 11.1-12.0 * *
Background:-moz-linear-gradient (right, red, blue); * * Firefox 3.6-15 * *
Background:linear-gradient (to right, red, blue); /* STANDARD Syntax * *
}

Linear gradient-Diagonal

You can make a diagonal gradient by specifying a horizontal and vertical starting position.

The following example shows a linear gradient starting from the upper-left corner (to the lower-right corner). Starting point is red, slowly transition to blue: instance

Linear gradient from upper-left to lower-right corner: #grad {
Background:-webkit-linear-gradient (left Top, red, blue); * Safari 5.1-6.0 * *
Background:-o-linear-gradient (bottom right, red, blue); * Opera 11.1-12.0 * *
Background:-moz-linear-gradient (bottom right, red, blue); * * Firefox 3.6-15 * *
Background:linear-gradient (to bottom right, red, blue); /* STANDARD Syntax * *
}


Use angle

If you want to do more control in the direction of the gradient, you can define an angle instead of the predefined direction (to bottom, to top, to right, to left, to bottom right, and so on). Grammar background:linear-gradient (angle, COLOR-STOP1, COLOR-STOP2);

The angle is the angle between the horizontal and gradient lines and is calculated counterclockwise. In other words, 0deg will create a gradient from bottom to top, and 90deg will create a gradient from left to right.

However, note that many browsers (CHROME,SAFARI,FIEFOX, etc.) use the old standard, that 0deg will create a gradient from bottom to top, 90deg will create a gradient from left to right. The conversion formula 90-x = y where x is the standard angle and y is a non-standard angle.

The following example shows how to use an angle on a linear gradient: an instance

Linear gradient with the specified angle: #grad {
  background:-webkit-linear-gradient (180deg, red, blue);/* Safari 5.1-6.0/
  Background:-o-linear-gradient (180deg, red, blue); /* Opera 11.1-12.0/*
  background:-moz-linear-gradient (180deg, red, blue);/* Firefox 3.6-15/
  ; Background:linear-gradient (180deg, red, blue); /* Standard syntax * *
}

Radial gradient: background:radial-gradient (center, shape size, Start-color, ..., last-color);

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.