Methods for setting gradient colors in CSS include: using linear-gradient() to create linear gradients. Use radial-gradient() to create a radial gradient. Use repeating-linear-gradient() and repeating-radial-gradient() to create repeating gradients.
How to use CSS to set gradient colors
Introduction
Gradient colors on web pages Widely used in design, it can be used to create eye-catching visual effects. CSS provides a variety of ways to set gradient colors.
Method 1: Use linear-gradient()
This is the simplest way to create a linear gradient. The syntax is as follows:
linear-gradient(direction, color-stop1, color-stop2, ...);
to bottom
) Example:
linear-gradient(to bottom, #ff0000, #00ff00);
Method 2: Using radial-gradient()
This method creates a radial gradient that radiates outward from a center point. The syntax is as follows:
radial-gradient(shape, size, start-color, end-color);
circle
or ellipse
)100px
) Example:
radial-gradient(circle, 100px, #0000ff, #ffffff);
Method 3: Use repeating- linear-gradient()
and repeating-radial-gradient()
These methods create repeating gradients. The syntax is similar to the corresponding linear-gradient()
and radial-gradient()
, but with the added repeating-
prefix.
Other properties
Example:
background: linear-gradient(to bottom, red, yellow); background-position: left top; background-size: 100% 50%; background-clip: content-box;
The above is the detailed content of How to set gradient color in css. For more information, please follow other related articles on the PHP Chinese website!