×

Radial-gradient() CSS function

Radial-gradient() CSS function

It defines a CSS in-built function, which produces a smooth transition among multiple colors. It is used to set any radial-gradient that is same as a background-image. This function can be the elliptical or circular shape.

It can save the usages of bandwidth and also helps to decrease the time of download. The color appears from an individual point; expand outwards in the radial-gradient. The radial-gradient can be depicted via its ending shape and center point and multiple stop.

Syntax:

background-image: radial-gradient(shape size at position, start-color, ..., last-color);  

Following are some arguments:

position: This argument depicts a gradient position. ‘Center’ is its default value. It is described in units (like em, px, etc.) or keywords (such as left, bottom, etc.).

shape: It can portray the gradient’s shape, which can be elliptical or circular. When its value isn’t described, then it can set to the default value that is an ellipse.

size: It represents the size of a gradient. It has some possible values which are listed below:

  • closest-side
  • closest-corner
  • farthest-side
  • farthest-corner

It has a default value, i.e., farthest-corner.

start-color, …., last-color: This argument holds the color value pursued by a stop position (optional).

Let’s understand the CSS function radial-gradient with the use of some examples.

Example:

<!DOCTYPE html>   
<html>   
<head>   
<title> CSS Gradients </title>   
<style>    
#main
{ 
background-image: radial-gradient(black, lime, blue, orange); 
} 
.hello
{   
text-align:center;   
font-size:40px; 
color:white; 
font-weight:bold;   
padding:100px;   
}   
</style>   
</head>   
<body>   
<div id="main">   
<div class = "hello"> Hello World </div>     
</div>   
</body>   
</html>  

Output:

Radial-gradient() CSS function

Consider the below examples:

Example:1

In the following illustration, we will set the radial-gradient’s shape.

<!DOCTYPE html>   
<html>   
<head>   
<title> CSS Gradients </title>   
<style>    
#main
{ 
height: 400px;   
width: 600px;   
background-image: radial-gradient(circle, black, yellow, blue, red, purple, green, orange); 
} 
.hello
{   
text-align:center;   
font-size:40px; 
color:white; 
font-weight:bold;   
padding:130px;   
}
.div2
{
font-size: 35px;
color: white;
text-align: center;
}  
</style>   
</head>   
<body>   
<div id="main">   
<div class = "hello"> Hello World!! </div> 
<div class = "div2"> Welcome to the Tutorial and Example. </div>       
</div>   
</body>   
</html>  

Output:

Radial-gradient() CSS function

Example:2

In the following illustration, we will set the radial-gradient’s size.

<!DOCTYPE html>   
<html>   
<head>   
<title>CSS Gradients</title>   
<style>
.demo div
{ 
float: left; 
} 
.demo1 div
{ 
float: left; 
} 
#main1
{   
height: 400px;   
width: 600px;   
background-image: radial-gradient(farthest-side at left bottom, blue, lime, green);   
margin:20px; 
} 
#main2
{   
height: 400px;   
width: 600px; 
background-image: radial-gradient(farthest-corner at right bottom , orange, tomato, red);   
margin:20px; 
} 
#main3
{   
height: 400px;   
width: 600px;   
background-image: radial-gradient(closest-side , lightblue, blue, navy);         
margin:20px; 
}   
#main4
{   
height: 400px;   
width: 600px;   
background-image: radial-gradient(closest-corner , yellow, orange, red);   
margin:20px; 
}   
.size
{   
text-align:center;   
font-size:40px; 
color:black; 
font-weight:bold;   
padding-top :130px;   
}   
</style>   
</head>   
<body>   
<div class="demo"> 
<div id="main1">   
<div class = "size">farthest-side at left bottom</div>     
</div>   
<div id="main2">   
<div class = "size">farthest-corner at right bottom</div>     
</div>  
</div>         
<div class="demo1">        
<div id="main3">   
<div class = "size">closest-side</div>     
</div>   
<div id="main4">   
<div class = "size">closest-corner</div>     
</div> 
</div> 
</body>   
</html> 

Output:

Radial-gradient() CSS function

Related Topics

CSS Vertical Align

Vertical Align The vertical align CSS property describes the cell box of the table and an inline alignment vertically. This property is a self-explanatory and an essential property in CSS. But,...

2 minutes read.

CSS Table

CSS table provides better look and feel. There are various properties of CSS table that are given below. border border-collapse padding width height text-align color background-color CSS Table Border You can set...

4 minutes read.

CSS Gradient

CSS Gradient: The CSS gradient property is applied to show the smooth transition inside two specified colors or more than two specified colors. Need of CSS Gradient The following are a few...

4 minutes read.

CSS Zoom

CSS Zoom: Zoom property in CSS extents the content. This property controls the content’s level of magnification. Rather than the use of this CSS property, we may also apply the...

3 minutes read.

Is CSS a programming language?

 A programming language is a set of grammatical rules and a vocabulary for commanding a machine to accomplish specified tasks. High-level languages like BASIC, C, C++, COBOL, Java, FORTRAN, Ada...

4 minutes read.

How to Set Space between the Flexbox

For managing layout on the Web, CSS Flexbox and CSS Grid are two excellent tools. Flexbox handles one-dimensional layouts quite well, whereas CSS Grid manages two-dimensional layouts with columns and...

4 minutes read.

CSS Image Gallery

Image galleries are used to display and store collections of images. Example Let’s discuss an example. CSS was used to create the following image gallery: Code is as follows: <html> <head> <style> div.gallery {   margin: 6px;   border: 1px...

5 minutes read.

CSS Syntax

The CSS syntax contains the selector and the declaration block, which will be clearer with the following example: Selector: A CSS selector specifies the HTML tag we wish to style. A selector can be...

2 minutes read.

CSS Tutorial

CSS refers to the Cascading Style Sheet. CSS is a form of a programming language. In other words, CSS is a language of the style sheet that is utilised for...

9 minutes read.

CSS Filter

CSS Filter CSS filter is used to apply visual effects on the images, text, and other factors of the webpage. This filter property in CSS allows us to admit the effects like...

7 minutes read.

CSS Page-break-inside Attribute

Page-break-inside Attribute As its name implies, the page-break-before property is applied to include page break inside any element, at the time of printing any document. It adds the page break before...

3 minutes read.

CSS Units

CSS Units In CSS, there are so many units available to show the length’s measurement. A single unit of CSS is applied to examine the size of the property, which the...

5 minutes read.

How to center a button in CSS

How to center a button in CSS? In the tutorial, we will learn how to center a button in CSS. CSS (Cascading Style Sheets) gives an HTML web page the greatest possible...

4 minutes read.

CSS Text-Overflow

Introduction: The text-overflow property of CSS is used to format the text which is overflowing the boundaries of the container. This property helps user to clip the text, to display the...

5 minutes read.

CSS Flex-Box

Introduction The flex-box property of CSS stands for Flexible Box Layout Module. It is specifically used to design a flexible responsive layout. Flex-box is a one dimensional layout model, i.e. it works...

6 minutes read.

CSS Outline

CSS Outline: This CSS property is quite similar to the border property of CSS. It eases us to design an additional border around the element to obtain visual attention. The...

4 minutes read.

Difference between CSS Grid and CSS Flexbox

The way that information is arranged on a website reveals a lot about you or your company. Organizational abilities are just as important as having the right materials. The design...

3 minutes read.

How to include CSS

How to include CSS CSS is included in HTML pages for formatting the documents based on the information inside a style sheet. We can add CSS in HTML documents in the following three ways: Inline...

5 minutes read.

CSS Text Effects

Text Effects in CSS We can use distinct text effects used inside the HTML document. Few attributes can be applied to insert the text effects. We can also style various web documents...

5 minutes read.

CSS Position

CSS Position: The position property in CSS is applied to set the position of the elements. It can be used to position the backside of an element. It is also...

3 minutes read.