×

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 Color Keywords

Here, we will discuss the following keywords: transparent currentcolor Inherit Transparent keyword A color can generally be made transparent by using the transparent keyword. Often it is used to for all intents...

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.

Hover condition for a:before and a:after in CSS

In CSS, :after and :before are used to add content after and before the element. The CSS pseudo-class is used to add some styling effect to the webpage. We can change...

4 minutes read.

CSS Font-Size

A Cascading Style Sheet (CSS) is a simple design scripting language intended to simplify the process of making web pages more visually appealing with the kind of high-level formatting. Cascading...

3 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.

CSS Background Color

It is one of the CSS properties to apply styling to html elements.This property is used to apply the background color to any HTML element.The background of an element includes...

2 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 Text Orientation

Introduction: The text-orientation property of CSS is used to specify the orientation of the text characters in the line of content. This property applies only with the vertical writing-mode and not...

4 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 Word Wrap

Word Wrap in CSS: The word-wrap property in CSS is referred to break any lengthy word and wrap towards the next or following line. It is employed for preventing overflow...

1 minute read.

CSS Text-align

Text-align The text-align property of CSS sets the table-cell box’s horizontal alignment or any block element. The text-align property is the same as the CSS property vertical-align but towards any horizontal...

1 minute read.

CSS Line Height

CSS Line Height: This property in CSS can be used to describe the line box’s minimal height inside the element. It sets-up the distinction among two lines in our content. It...

3 minutes read.

CSS Lists

CSS Lists: Several properties are available in CSS that are used to manage the lists. Lists are distributed as ordered and unordered kind of lists. The ordered lists provide the...

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 Superscript and Subscript

Superscript and Subscript To specify the superscript and the subscript text, HTML provides us two tags that are <sup> and <sub>. The superscript content looks in the shorter font and half...

2 minutes read.

CSS Page-break-after Attribute

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

5 minutes read.

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...

4 minutes read.

CSS z-index Property

CSS z-index: CSS z-index permits us to represent any visual hierarchy over a 3D plane that is the z-axis. This index can be applied to describe the positioned element’s stacking...

2 minutes read.

CSS Content Property

Content Property The content attribute produces dynamic content. It can be applied with any pseudo-element ::after and ::before. These CSS properties are entirely supported inside every browser and applied to include...

5 minutes read.

CSS Pseudo-elements

Pseudo-elements The pseudo-classes in CSS can be represented as any keyword which is connected to the selector that represents any selected element’s unique state. On the other hand, pseudo-elements can be...

6 minutes read.