The Wayback Machine - https://web.archive.org/web/20231205212024/https://www.geeksforgeeks.org/how-css-transition-work-with-linear-gradient-background-button/
Open In App
Related Articles

How CSS transition work with linear gradient background button?

Improve Article
Improve
Save Article
Save
Like Article
Like

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>


Output:


Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out - check it out now!

Last Updated : 22 May, 2020
Like Article
Save Article
Previous
Next
Similar Reads
Complete Tutorials