In CSS, you can smoothly make transitions between two or more colors. CSS has two types of gradients:
- Linear gradient: It goes down/up/left/right/diagonally and makes smooth transitions of colors. To make a linear transition you first have to choose two color stops. Color stops are the color among which you want to make the transitions. You can also select a starting point and a direction(an angle) for the transition.
background-image: linear-gradient(direction, color-stop1, color-stop2, …); - Radial gradient: It is defined by the center. Here also you have to specify at least two color spots.
Syntax:
background-image: radial-gradient(shape size at position, start-color, ...);
Example:
<!DOCTYPE html> <html> <head> <title> Transition work with linear gradient background button </title> <style> button { background-image: linear-gradient(to bottom right, green, white); } button:hover { background-image: linear-gradient(to bottom right, green, yellow); } h1 { color: green; } </style> </head> <body> <center> <h1>GeeksforGeeks</h1> <b>Hover over the bytton</b> <br> <br> <button>Click me</button> </center> </body> </html> |
chevron_right
filter_none
Output:

Recommended Posts:
- CSS | linear-gradient() Function
- CSS | repeating-linear-gradient() Function
- How to create linear-gradient color generator using HTML, CSS and JavaScript ?
- How to create linear gradient text using HTML and CSS ?
- Why Transition properties does not work with display properties ?
- CSS | Combine background image with gradient overlay
- How to Create Gradient Background Animation using HTML and CSS ?
- CSS | transition-delay Property
- Transition shorthand with multiple properties in CSS?
- CSS | transition-property Property
- CSS | transition Property
- CSS | transition-duration Property
- CSS | transition-timing-function Property
- How to Linearly Transition the removal of a DOM element using CSS and JavaScript ?
- CSS | radial-gradient() Function
- CSS | repeating-radial-gradient() Function
- How to draw a circle with gradient border using CSS ?
- CSS | conic-gradient() Function
- Create a Gradient Text Effect using HTML and CSS
- How order of classes work in CSS ?
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


