Setting the Location Color Stops using CSS

CSSWeb DevelopmentFront End Technology

The location at color stops can be set as a percentage or absolute length. For example, for linear gradient

background-image: linear-gradient(
   rgb(61, 255, 2) 40%,
   rgb(0, 174, 255) 80%,
   rgb(255, 29, 29) 20%
);

Following is the code for setting the location color stops in linear gradient using CSS −

Example

 Live Demo

<!DOCTYPE html>
<html>
<head>
<style>
body {
   font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
}
.even {
   height: 100px;
   background-image: linear-gradient(
      rgb(61, 255, 2),
      rgb(0, 174, 255),
      rgb(255, 29, 29)
   );
}
.uneven {
   height: 100px;
   background-image: linear-gradient(
      rgb(61, 255, 2) 40%,
      rgb(0, 174, 255) 80%,
      rgb(255, 29, 29) 20%
   );
}
</style>
</head>
<body>
<h1>Linear gradient location color stops</h1>
<h3>Evenly Spaced</h3>
<div class="even"></div>
<h3>Unevenly Spaced</h3>
<div class="uneven"></div>
</body>
</html>

Output

The above code will produce the following output −

raja
Published on 12-May-2020 09:34:22
Advertisements