Home > Article > Web Front-end > How to set gradient color in css
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:
<code class="css">linear-gradient(direction, color-stop1, color-stop2, ...);</code>
to bottom
) Example:
<code class="css">linear-gradient(to bottom, #ff0000, #00ff00);</code>
Method 2: Using radial-gradient()
This method creates a radial gradient that radiates outward from a center point. The syntax is as follows:
<code class="css">radial-gradient(shape, size, start-color, end-color);</code>
circle
or ellipse
)100px
) Example:
<code class="css">radial-gradient(circle, 100px, #0000ff, #ffffff);</code>
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:
<code class="css">background: linear-gradient(to bottom, red, yellow); background-position: left top; background-size: 100% 50%; background-clip: content-box;</code>
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!