fight coronavirus(corvid-19) - As they treat the sick & find the solution, please stay at home + wash your hands every after activity, GOD bless you.
Learn how to create Gradient Backgrounds using CSS

As you might know, HTML5 introduced many exciting features for Web developers. One of the features is the ability to specify gradients using pure CSS3, without having to create any images and use them as repeating backgrounds for gradient effects.

Gradients let you display smooth transitions between two or more specified colors.

The linear-gradient() CSS function creates an image consisting of a progressive transition between two or more colors along a straight line.

More so, Its result is an object of the gradient data type, which is a special kind of image.

Tutorial

To follow the tutorial above, create two files i.e index.html and style.css and add the code below respectively.

HTML

Add this code in the body section of your html document(index.html).

copy


   <div class="container">

     <div class="box"> </div>
     <div class="box"> </div>
     <div class="box"> </div>
     <div class="box"> </div>

   </div>


CSS

Add this code in the style.css file you created and link to it in the head section of the index.html file.

copy

body{
margin:0;
padding:0;
box-sizing: border-box;
}

.container{
max-width: 80%;
margin:0 auto;
display: grid;
grid-template-columns: repeat(4,1fr);
grid-gap:10px;
}


.box{
width:100px;
height:150px;
margin-top:250px;

/*Fallback color incase all fail.*/
background-color:#333;

/*For Old Browsers.*/
background-image:-webkit-gradient(linear, left top, left bottom, from(#333),to(#fff));
background-image:-webkit-linear-gradient(top,#333,#fff);
background-image:-o-linear-gradient(top,#333,#fff);
background-image:-ms-linear-gradient(top,#333,#fff);
background-image:-moz-linear-gradient(top,#333,#fff);

/*Upto date Browsers.*/
background-image:linear-gradient(to bottom,#333,#fff);
}
	

You See gradients were super played out back in the early web days, but now they’re so ubiquitous that you’d be remiss not to drop them in your site or interface. So have fun trying out new gradient backgrounds.

Related Post(s)

» Creating A Pure CSS Preloader - Source Code

» Learn how to use CSS box shadow property - Source Code

» How to create Text Animation using HTML and CSS

» Learn how to create Gradient Backgrounds using CSS

» How to use the CSS Negation and Language Selectors.

collections_bookmark Category :: Css
date_range Published :: 1 month ago At: 01:04 AM
event_note Detailed Date :: Jun 01st, 2020
person Writer :: Code

YOU MAY LIKE THESE POSTS

share