Hướng dẫn text gradient css w3schools
Gradient Backgrounds Show CSS gradients let you display smooth transitions between two or more specified colors. CSS defines three types of gradients:
CSS Linear GradientsTo create a linear gradient you must define at least two color stops. Color stops are the colors you want to render smooth transitions among. You can also set a starting point and a direction (or an angle) along with the gradient effect. Syntaxbackground-image: linear-gradient(direction, color-stop1, color-stop2, ...); Direction - Top to Bottom (this is default) The following example shows a linear gradient that starts at the top. It starts red, transitioning to yellow: top to bottom (default) Direction - Left to Right The following example shows a linear gradient that starts from the left. It starts red, transitioning to yellow: left to right Example #grad { Try it Yourself » Direction - Diagonal You can make a gradient diagonally by specifying both the horizontal and vertical starting positions. The following example shows a linear gradient that starts at top left (and goes to bottom right). It starts red, transitioning to yellow: top left to bottom right Example #grad { Try it Yourself » Using AnglesIf you want more control over the direction of the gradient, you can define an angle, instead of the predefined directions (to bottom, to top, to right, to left, to bottom right, etc.). A value of 0deg is equivalent to "to top". A value of 90deg is equivalent to "to right". A value of 180deg is equivalent to "to bottom". Syntaxbackground-image: linear-gradient(angle, color-stop1, color-stop2); The following example shows how to use angles on linear gradients: 180deg Example #grad { Try it Yourself » Using Multiple Color StopsThe following example shows a linear gradient (from top to bottom) with multiple color stops: Example #grad { Try it Yourself » The following example shows how to create a linear gradient (from left to right) with the color of the rainbow and some text: Rainbow Background
Example #grad { Try it Yourself » Using TransparencyCSS gradients also support transparency, which can be used to create fading effects. To add transparency, we use the rgba() function to define the color stops. The last parameter in the rgba() function can be a value from 0 to 1, and it defines the transparency of the color: 0 indicates full transparency, 1 indicates full color (no transparency). The following example shows a linear gradient that starts from the left. It starts fully transparent, transitioning to full color red: Example #grad { Try it Yourself » Repeating a linear-gradientThe repeating-linear-gradient() function is used to repeat linear gradients: ExampleA repeating linear gradient: #grad { Try it Yourself » ❮ CSS Functions Reference ExampleThis linear gradient starts at the top. It starts red, transitioning to yellow, then to blue: #grad { Try it Yourself » More "Try it Yourself" examples below. Definition and UsageThe linear-gradient() function sets a linear gradient as the background image. To create a linear gradient you must define at least two color stops. Color stops are the colors you want to render smooth transitions among. You can also set a starting point and a direction (or an angle) along with the gradient effect. Example of Linear Gradient:
Browser SupportThe numbers in the table specify the first browser version that fully supports the function. Numbers followed by -webkit-, -moz-, or -o- specify the first version that worked with a prefix.
CSS Syntaxbackground-image: linear-gradient(direction, color-stop1, color-stop2, ...);
More ExamplesExampleA linear gradient that starts from the left. It starts red, transitioning to blue: #grad { Try it Yourself » ExampleA linear gradient that starts at top left (and goes to bottom right): #grad { Try it Yourself » ExampleA linear gradient with a specified angle: #grad { Try it Yourself » ExampleA linear gradient with multiple color stops: #grad { Try it Yourself » ExampleA linear gradient with transparency: #grad { Try it Yourself » Related PagesCSS tutorial: CSS Gradients ❮ CSS Functions Reference |