AdBlock Detected!
Our website is made possible by displaying ads to our visitors. Please supporting us by whitelisting our website.
CSS Linear-Gradient Property |
In a linear gradient background, the colors gradually transition from one to the other either vertically, horizontally, or at an angle. The linear-gradient property in CSS controls how this type of gradient is displayed as the background. The syntax for linear-gradient is as follows:
<arguments> are variables that specify what the linear gradient would exactly look like. There are several types of arguments for linear-gradient, including color, direction, and color stop location. Below are examples that illustrate commonly-used arguments: Example 1: Simple linear gradient CSS Declaration
Result: This is the most simple way of specifying a linear gradient. With two colors and no other arguments, the browser will set the background color at the top to the first color specified (in this case red), set the background color at the bottom to the second color specified (in this case yellow), and apply a linear gradient between the top and the bottom. Example 2: Specify direction CSS Declaration
Result: When we use the "to <direction>" argument, we are telling the browser what direction the gradient should flow. In Example 2, the background color starts out as red (the first color specified) on the right, and then gradually shits to yellow (the second color specified) towards left. Example 3: Specify angle CSS Declaration
Result: When we specify an angle, the direction of the linear gradient is shifted by that angle. Example 4: Multiple color stops CSS Declaration
Result: In Example 4, we specified a color, a percentage, a second color, a second percentage, and a third color. The two percentage values are where the color stops occur. Three distinct background segments result from this CSS declaration:
One thing to note above is that only a single background color exists in the first segment as well as in the third segment. This illustrates that linear-gradient can also be used to set part of the background to a single color.
|
Our website is made possible by displaying ads to our visitors. Please supporting us by whitelisting our website.