以下是一个简单的例子,演示了如何在CSS中使用`linear-gradient`函数: ```css /*创建一个从上到下的渐变背景*/ .gradient-example1 { background: linear-gradient(to bottom, #ffcc00, #ff6600); height: 200px; } /*创建一个从左上到右下的渐变背景*/ .gradient-example2 { background: linear-...
从蓝色渐变到红色 */linear-gradient(45deg, blue, red);/* 从右下到左上、从蓝色渐变到红色 */linear-gradient(tolefttop, blue, red);/* 从下到上,从蓝色开始渐变、到高度40%位置是绿色渐变开始、最后以红色结束 */linear-gradient(0deg, blue, green40%, red);...
A linear gradient is defined by an axis—thegradient line—and two or morecolor-stop points. Each point on the axis is a distinct color; to create a smooth gradient, thelinear-gradient()function draws a series of colored lines perpendicular to the gradient line, each one matching the color...
.gradient{height:100px;background-image:linear-gradient(green, yellow, blue);Text-align:center;padding-top:40px;font-size:40px;color:white;font-weight:bold; }h2{text-align:center; } linear-gradient:ToptoBottomproperty GeeksforGeeks 輸出: 範例2: <!DOCTYPEhtml> linear-gradientfunction...
gradient line/语法 [Composition of a linear gradient] A linear gradient is defined by an axis—thegradient line—and two or morecolor-stop points. Each point on the axis is a distinct color; to create a smooth gradient, thelinear-gradient() function draws a series of colored...
在本文,将用10个简单示例,介绍CSSlinear-gradient()背景颜色渐变的使用方法。 css语法 background: linear-gradient(direction,color-stop1,color-stop2,...); direction:指定渐变的方向(或角度); color-stop1,color-stop2,...:用于指定渐变的起止颜色(至少需要两种颜色) ...
The linear-gradient() CSS function creates an image consisting of a progressive transition between two or more colors along a straight line. Its result is an object of the <gradient> data type, which is a special kind of <image>.
linear-gradient() 函数用于创建一个表示两种或多种颜色线性渐变的图片。 创建一个线性渐变,需要指定两种颜色,还可以实现不同方向(指定为一个角度)的渐变效果,如果不指定方向,默认从上到下渐变。 /*从上到下,蓝色渐变到红色*/linear-gradient(blue,red);/*渐变轴为45度,从蓝色渐变到红色*/linear-gradient(45deg...
A linear gradient CSS property is defined by its color flow in a single direction. You can set the gradient to flow from left to right, top to bottom, or at any other angle. Before you continue, it’s important to note that gradients in CSS are treated as images. When you create a...
Example of a linear gradient from top to bottom: <!DOCTYPE html> Title of the document .gradient { height: 300px; background-color: blue; background-image: linear-gradient(#0052b0, #b340b3); } Try it Yourself » We add background-color for browsers that do not...