Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you make a gradient background in css?

Tags:

Is there any way to create a gradient background using nothing but CSS?

You can see an example of what I want to achieve on this website.

like image 888
user1179295 Avatar asked Feb 24 '12 10:02

user1179295


People also ask

What is background gradient in CSS?

Gradient Backgrounds. CSS gradients let you display smooth transitions between two or more specified colors. CSS defines three types of gradients: Linear Gradients (goes down/up/left/right/diagonally) Radial Gradients (defined by their center)

Can background color be a gradient?

Just as you can declare the background of an element to be a solid color in CSS, you can also declare that background to be a gradient.


2 Answers

Use this in your CSS:

background-image: -o-linear-gradient(bottom, rgb(254,133,107) 24%, rgb(35,171,17) 62%); background-image: -moz-linear-gradient(bottom, rgb(254,133,107) 24%, rgb(35,171,17) 62%); background-image: -webkit-gradient(linear, left bottom, left top, color-stop(0.24, rgb(254,133,107)), color-stop(0.62, rgb(35,171,17))); background-image: -webkit-linear-gradient(bottom, rgb(254,133,107) 24%, rgb(35,171,17) 62%); background-image: -ms-linear-gradient(bottom, rgb(254,133,107) 24%, rgb(35,171,17) 62%); /* This last line is all you need for modern browsers */ background-image: linear-gradient(bottom, rgb(254,133,107) 24%, rgb(35,171,17) 62%); 

See also:

  • The specification
  • The MDN documentation
like image 191
Ghost Answer Avatar answered Nov 09 '22 21:11

Ghost Answer


Simple and easy to make. Try this link

/* IE10 Consumer Preview */  background-image: -ms-linear-gradient(top, #FCFEFF 0%, #AF00EF 100%);  /* Mozilla Firefox */  background-image: -moz-linear-gradient(top, #FCFEFF 0%, #AF00EF 100%);  /* Opera */  background-image: -o-linear-gradient(top, #FCFEFF 0%, #AF00EF 100%);  /* Webkit (Safari/Chrome 10) */  background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0, #FCFEFF), color-stop(1, #AF00EF));  /* Webkit (Chrome 11+) */  background-image: -webkit-linear-gradient(top, #FCFEFF 0%, #AF00EF 100%);  /* W3C Markup, IE10 Release Preview */  background-image: linear-gradient(to bottom, #FCFEFF 0%, #AF00EF 100%); 
like image 25
Abhishek Avatar answered Nov 09 '22 22:11

Abhishek