CSS Gradients

CSS Tutorial


Notice: Trying to get property 'post_status' of non-object in /home/u212091429/domains/mydevhelp.com/public_html/wp-admin/includes/template.php on line 2298

Notice: Trying to get property 'post_status' of non-object in /home/u212091429/domains/mydevhelp.com/public_html/wp-admin/includes/template.php on line 2302

Notice: Trying to get property 'post_status' of non-object in /home/u212091429/domains/mydevhelp.com/public_html/wp-admin/includes/template.php on line 2308

Notice: Trying to get property 'post_status' of non-object in /home/u212091429/domains/mydevhelp.com/public_html/wp-admin/includes/template.php on line 2312

Notice: Trying to get property 'ID' of non-object in /home/u212091429/domains/mydevhelp.com/public_html/wp-admin/includes/template.php on line 2316

Notice: Trying to get property 'post_status' of non-object in /home/u212091429/domains/mydevhelp.com/public_html/wp-admin/includes/template.php on line 2320

Notice: Trying to get property 'ID' of non-object in /home/u212091429/domains/mydevhelp.com/public_html/wp-admin/includes/template.php on line 2334

Notice: Trying to get property 'post_status' of non-object in /home/u212091429/domains/mydevhelp.com/public_html/wp-admin/includes/template.php on line 2298

Notice: Trying to get property 'post_status' of non-object in /home/u212091429/domains/mydevhelp.com/public_html/wp-admin/includes/template.php on line 2302

Notice: Trying to get property 'post_status' of non-object in /home/u212091429/domains/mydevhelp.com/public_html/wp-admin/includes/template.php on line 2308

Notice: Trying to get property 'post_status' of non-object in /home/u212091429/domains/mydevhelp.com/public_html/wp-admin/includes/template.php on line 2312

Notice: Trying to get property 'ID' of non-object in /home/u212091429/domains/mydevhelp.com/public_html/wp-admin/includes/template.php on line 2316

Notice: Trying to get property 'post_status' of non-object in /home/u212091429/domains/mydevhelp.com/public_html/wp-admin/includes/template.php on line 2320

Notice: Trying to get property 'ID' of non-object in /home/u212091429/domains/mydevhelp.com/public_html/wp-admin/includes/template.php on line 2334

Notice: Trying to get property 'post_status' of non-object in /home/u212091429/domains/mydevhelp.com/public_html/wp-admin/includes/template.php on line 2298

Notice: Trying to get property 'post_status' of non-object in /home/u212091429/domains/mydevhelp.com/public_html/wp-admin/includes/template.php on line 2302

Notice: Trying to get property 'post_status' of non-object in /home/u212091429/domains/mydevhelp.com/public_html/wp-admin/includes/template.php on line 2308

Notice: Trying to get property 'post_status' of non-object in /home/u212091429/domains/mydevhelp.com/public_html/wp-admin/includes/template.php on line 2312

Notice: Trying to get property 'ID' of non-object in /home/u212091429/domains/mydevhelp.com/public_html/wp-admin/includes/template.php on line 2316

Notice: Trying to get property 'post_status' of non-object in /home/u212091429/domains/mydevhelp.com/public_html/wp-admin/includes/template.php on line 2320

Notice: Trying to get property 'ID' of non-object in /home/u212091429/domains/mydevhelp.com/public_html/wp-admin/includes/template.php on line 2334

Notice: Trying to get property 'post_status' of non-object in /home/u212091429/domains/mydevhelp.com/public_html/wp-admin/includes/template.php on line 2298

Notice: Trying to get property 'post_status' of non-object in /home/u212091429/domains/mydevhelp.com/public_html/wp-admin/includes/template.php on line 2302

Notice: Trying to get property 'post_status' of non-object in /home/u212091429/domains/mydevhelp.com/public_html/wp-admin/includes/template.php on line 2308

Notice: Trying to get property 'post_status' of non-object in /home/u212091429/domains/mydevhelp.com/public_html/wp-admin/includes/template.php on line 2312

Notice: Trying to get property 'ID' of non-object in /home/u212091429/domains/mydevhelp.com/public_html/wp-admin/includes/template.php on line 2316

Notice: Trying to get property 'post_status' of non-object in /home/u212091429/domains/mydevhelp.com/public_html/wp-admin/includes/template.php on line 2320

Notice: Trying to get property 'ID' of non-object in /home/u212091429/domains/mydevhelp.com/public_html/wp-admin/includes/template.php on line 2334

Notice: Trying to get property 'post_status' of non-object in /home/u212091429/domains/mydevhelp.com/public_html/wp-admin/includes/template.php on line 2298

Notice: Trying to get property 'post_status' of non-object in /home/u212091429/domains/mydevhelp.com/public_html/wp-admin/includes/template.php on line 2302

Notice: Trying to get property 'post_status' of non-object in /home/u212091429/domains/mydevhelp.com/public_html/wp-admin/includes/template.php on line 2308

Notice: Trying to get property 'post_status' of non-object in /home/u212091429/domains/mydevhelp.com/public_html/wp-admin/includes/template.php on line 2312

Notice: Trying to get property 'ID' of non-object in /home/u212091429/domains/mydevhelp.com/public_html/wp-admin/includes/template.php on line 2316

Notice: Trying to get property 'post_status' of non-object in /home/u212091429/domains/mydevhelp.com/public_html/wp-admin/includes/template.php on line 2320

Notice: Trying to get property 'ID' of non-object in /home/u212091429/domains/mydevhelp.com/public_html/wp-admin/includes/template.php on line 2334

Notice: Trying to get property 'post_status' of non-object in /home/u212091429/domains/mydevhelp.com/public_html/wp-admin/includes/template.php on line 2298

Notice: Trying to get property 'post_status' of non-object in /home/u212091429/domains/mydevhelp.com/public_html/wp-admin/includes/template.php on line 2302

Notice: Trying to get property 'post_status' of non-object in /home/u212091429/domains/mydevhelp.com/public_html/wp-admin/includes/template.php on line 2308

Notice: Trying to get property 'post_status' of non-object in /home/u212091429/domains/mydevhelp.com/public_html/wp-admin/includes/template.php on line 2312

Notice: Trying to get property 'ID' of non-object in /home/u212091429/domains/mydevhelp.com/public_html/wp-admin/includes/template.php on line 2316

Notice: Trying to get property 'post_status' of non-object in /home/u212091429/domains/mydevhelp.com/public_html/wp-admin/includes/template.php on line 2320

Notice: Trying to get property 'ID' of non-object in /home/u212091429/domains/mydevhelp.com/public_html/wp-admin/includes/template.php on line 2334

CSS Advanced


Notice: Trying to get property 'post_status' of non-object in /home/u212091429/domains/mydevhelp.com/public_html/wp-admin/includes/template.php on line 2298

Notice: Trying to get property 'post_status' of non-object in /home/u212091429/domains/mydevhelp.com/public_html/wp-admin/includes/template.php on line 2302

Notice: Trying to get property 'post_status' of non-object in /home/u212091429/domains/mydevhelp.com/public_html/wp-admin/includes/template.php on line 2308

Notice: Trying to get property 'post_status' of non-object in /home/u212091429/domains/mydevhelp.com/public_html/wp-admin/includes/template.php on line 2312

Notice: Trying to get property 'ID' of non-object in /home/u212091429/domains/mydevhelp.com/public_html/wp-admin/includes/template.php on line 2316

Notice: Trying to get property 'post_status' of non-object in /home/u212091429/domains/mydevhelp.com/public_html/wp-admin/includes/template.php on line 2320

Notice: Trying to get property 'ID' of non-object in /home/u212091429/domains/mydevhelp.com/public_html/wp-admin/includes/template.php on line 2334

Notice: Trying to get property 'post_status' of non-object in /home/u212091429/domains/mydevhelp.com/public_html/wp-admin/includes/template.php on line 2298

Notice: Trying to get property 'post_status' of non-object in /home/u212091429/domains/mydevhelp.com/public_html/wp-admin/includes/template.php on line 2302

Notice: Trying to get property 'post_status' of non-object in /home/u212091429/domains/mydevhelp.com/public_html/wp-admin/includes/template.php on line 2308

Notice: Trying to get property 'post_status' of non-object in /home/u212091429/domains/mydevhelp.com/public_html/wp-admin/includes/template.php on line 2312

Notice: Trying to get property 'ID' of non-object in /home/u212091429/domains/mydevhelp.com/public_html/wp-admin/includes/template.php on line 2316

Notice: Trying to get property 'post_status' of non-object in /home/u212091429/domains/mydevhelp.com/public_html/wp-admin/includes/template.php on line 2320

Notice: Trying to get property 'ID' of non-object in /home/u212091429/domains/mydevhelp.com/public_html/wp-admin/includes/template.php on line 2334

Notice: Trying to get property 'post_status' of non-object in /home/u212091429/domains/mydevhelp.com/public_html/wp-admin/includes/template.php on line 2298

Notice: Trying to get property 'post_status' of non-object in /home/u212091429/domains/mydevhelp.com/public_html/wp-admin/includes/template.php on line 2302

Notice: Trying to get property 'post_status' of non-object in /home/u212091429/domains/mydevhelp.com/public_html/wp-admin/includes/template.php on line 2308

Notice: Trying to get property 'post_status' of non-object in /home/u212091429/domains/mydevhelp.com/public_html/wp-admin/includes/template.php on line 2312

Notice: Trying to get property 'ID' of non-object in /home/u212091429/domains/mydevhelp.com/public_html/wp-admin/includes/template.php on line 2316

Notice: Trying to get property 'post_status' of non-object in /home/u212091429/domains/mydevhelp.com/public_html/wp-admin/includes/template.php on line 2320

Notice: Trying to get property 'ID' of non-object in /home/u212091429/domains/mydevhelp.com/public_html/wp-admin/includes/template.php on line 2334

Notice: Trying to get property 'post_status' of non-object in /home/u212091429/domains/mydevhelp.com/public_html/wp-admin/includes/template.php on line 2298

Notice: Trying to get property 'post_status' of non-object in /home/u212091429/domains/mydevhelp.com/public_html/wp-admin/includes/template.php on line 2302

Notice: Trying to get property 'post_status' of non-object in /home/u212091429/domains/mydevhelp.com/public_html/wp-admin/includes/template.php on line 2308

Notice: Trying to get property 'post_status' of non-object in /home/u212091429/domains/mydevhelp.com/public_html/wp-admin/includes/template.php on line 2312

Notice: Trying to get property 'ID' of non-object in /home/u212091429/domains/mydevhelp.com/public_html/wp-admin/includes/template.php on line 2316

Notice: Trying to get property 'post_status' of non-object in /home/u212091429/domains/mydevhelp.com/public_html/wp-admin/includes/template.php on line 2320

Notice: Trying to get property 'ID' of non-object in /home/u212091429/domains/mydevhelp.com/public_html/wp-admin/includes/template.php on line 2334

Notice: Trying to get property 'post_status' of non-object in /home/u212091429/domains/mydevhelp.com/public_html/wp-admin/includes/template.php on line 2298

Notice: Trying to get property 'post_status' of non-object in /home/u212091429/domains/mydevhelp.com/public_html/wp-admin/includes/template.php on line 2302

Notice: Trying to get property 'post_status' of non-object in /home/u212091429/domains/mydevhelp.com/public_html/wp-admin/includes/template.php on line 2308

Notice: Trying to get property 'post_status' of non-object in /home/u212091429/domains/mydevhelp.com/public_html/wp-admin/includes/template.php on line 2312

Notice: Trying to get property 'ID' of non-object in /home/u212091429/domains/mydevhelp.com/public_html/wp-admin/includes/template.php on line 2316

Notice: Trying to get property 'post_status' of non-object in /home/u212091429/domains/mydevhelp.com/public_html/wp-admin/includes/template.php on line 2320

Notice: Trying to get property 'ID' of non-object in /home/u212091429/domains/mydevhelp.com/public_html/wp-admin/includes/template.php on line 2334

Notice: Trying to get property 'post_status' of non-object in /home/u212091429/domains/mydevhelp.com/public_html/wp-admin/includes/template.php on line 2298

Notice: Trying to get property 'post_status' of non-object in /home/u212091429/domains/mydevhelp.com/public_html/wp-admin/includes/template.php on line 2302

Notice: Trying to get property 'post_status' of non-object in /home/u212091429/domains/mydevhelp.com/public_html/wp-admin/includes/template.php on line 2308

Notice: Trying to get property 'post_status' of non-object in /home/u212091429/domains/mydevhelp.com/public_html/wp-admin/includes/template.php on line 2312

Notice: Trying to get property 'ID' of non-object in /home/u212091429/domains/mydevhelp.com/public_html/wp-admin/includes/template.php on line 2316

Notice: Trying to get property 'post_status' of non-object in /home/u212091429/domains/mydevhelp.com/public_html/wp-admin/includes/template.php on line 2320

Notice: Trying to get property 'ID' of non-object in /home/u212091429/domains/mydevhelp.com/public_html/wp-admin/includes/template.php on line 2334

CSS Responsive

CSS Grid

CSS Gradients

CSS gradients enable smooth transitions between two or more specified colors.

CSS specifies three types of gradients:

  • Linear Gradients (goes down/up/left/right/diagonally).
  • Radial Gradients (defined by their center).
  • Conic Gradients (rotated around a center point).

CSS Linear Gradients

To create a linear gradient at least two color stops are defined. Color stops are the colors that are used for smooth transitions. A starting point and a direction (or an angle) can be set along with the gradient effect.

Syntax

background-image: linear-gradient(direction, color-stop1, color-stop2, …);

Direction – Top to Bottom (this is default)

The example illustrates a linear gradient that starts at the top. It starts grey, transitioning to skyblue:

HTML
				
					<h1>Linear Gradient - Top to Bottom</h1>
<p>This linear gradient starts grey at the top, transitioning to skyblue at the bottom:</p>
<div id="grad1"></div>
				
			
CSS
				
					#grad1 {
  height: 200px;
  background-color: red; /* For browsers that do not support gradients */
  background-image: linear-gradient(grey, skyblue);
}
				
			

Output

linear gradient

Direction – Left to Right

The example illustrates a linear gradient that starts from the left. It begins red, transitioning to yellow:

HTML
				
					<h1>Linear Gradient - Left to right</h1>
<p>This linear gradient starts grey at the left, transitioning to skyblue at the right:</p>
<div id="grad1"></div>
				
			
CSS
				
					#grad1 {
height: 200px;
  background-color: grey; /* For browsers that do not support gradients */
  background-image: linear-gradient(to right, grey , skyblue);

}
				
			

Output

linear gradient left to right

Direction – Diagonal

Creating a gradient diagonally by defining both the horizontal and vertical starting positions.

The example illustrates a linear gradient that begins at top left (and goes to bottom right). It starts grey, transitioning to skyblue:

HTML

				
					<h1>Linear Gradient - Diagonal</h1>
<p>This linear gradient starts grey at top left, transitioning to skyblue (at bottom right):</p>
<div id="grad1"></div>
				
			
CSS
				
					#grad1 {
  height: 200px;
  background-color: grey; /* For browsers that do not support gradients */
  background-image: linear-gradient(to bottom right, grey, skyblue);
}
				
			

Output

Using Angles

To have more control over the direction of the gradient, you can do so by defining an angle, instead of using the predefined directions (to bottom, to top, to right, to left, to bottom right, etc.). A value of 0deg is equal to “to top”. A value of 90deg is equal to “to right”. A value of 180deg is equal to “to the bottom”.

Syntax

background-image: linear-gradient(angle, color-stop1, color-stop2);

HTML
				
					<h1>Linear Gradients - Using Different Angles</h1>
<div id="grad1" style="text-align:center;">0deg</div><br>
<div id="grad2" style="text-align:center;">90deg</div><br>
<div id="grad3" style="text-align:center;">180deg</div><br>
<div id="grad4" style="text-align:center;">-90deg</div>
				
			
CSS
				
					#grad1 {
  height: 100px;
  background-color: red; /* For browsers that do not support gradients */
  background-image: linear-gradient(0deg, grey, skyblue);
}

#grad2 {
  height: 100px;
  background-color: red; /* For browsers that do not support gradients */
  background-image: linear-gradient(90deg, grey, skyblue);
}

#grad3 {
  height: 100px;
  background-color: red; /* For browsers that do not support gradients */
  background-image: linear-gradient(180deg, grey, skyblue);
}

#grad4 {
  height: 100px;
  background-color: red; /* For browsers that do not support gradients */
  background-image: linear-gradient(-90deg, grey, skyblue);
}
				
			

Output

Using Multiple Color Stops

The example illustrates a linear gradient (from top to bottom) with multiple color stops:

HTML
				
					<h1>Linear Gradients - Multiple Color Stops</h1>
<p><strong>Note:</strong> Color stops are spaced evenly when no percents are specified.</p>
<h2>3 Color Stops (evenly spaced):</h2>
<div id="grad1"></div>
<h2>7 Color Stops (evenly spaced):</h2>
<div id="grad2"></div>
<h2>3 Color Stops (not evenly spaced):</h2>
<div id="grad3"></div>
				
			
CSS
				
					#grad1 {
  height: 200px;
  background-color: red; /* For browsers that do not support gradients */
  background-image: linear-gradient(red, yellow, green);
}

#grad2 {
  height: 200px;
  background-color: red; /* For browsers that do not support gradients */
  background-image: linear-gradient(red, orange, yellow, green, blue, indigo, violet);
}

#grad3 {
  height: 200px;
  background-color: red; /* For browsers that do not support gradients */
  background-image: linear-gradient(red 10%, green 85%, blue 90%);
}
				
			

Output


Notice: ob_end_flush(): failed to send buffer of zlib output compression (1) in /home/u212091429/domains/mydevhelp.com/public_html/wp-includes/functions.php on line 5420

Notice: ob_end_flush(): failed to send buffer of zlib output compression (1) in /home/u212091429/domains/mydevhelp.com/public_html/wp-includes/functions.php on line 5420