Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Building a 4 corners-colors CSS3 gradient

Tags:

Is it possible to produce the following gradient in CSS :

enter image description here

like image 816
500 Avatar asked Aug 26 '13 20:08

500


People also ask

Can we add gradient color in CSS?

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)

Which CSS property is used to create gradient background colors?

Gradients are background-image While declaring the a solid color uses background-color property in CSS, gradients use background-image .

How many Colours can you pick for a gradient background?

To create the most basic type of gradient, all you need is to specify two colors. These are called color stops. You must have at least two, but you can have as many as you want.


1 Answers

in your case

enter image description here

Method 1:

jsFiddle Demo

div{ overflow: hidden; background: #f06; background: linear-gradient(45deg, #fff722, #ff26f9); min-height: 100%; width: 256px; height: 256px; position: relative; z-index: 1; box-shadow: inset -20px 0 38px -18px #ff26f9,inset -3px -13px 65px -18px yellow; }  div:before,div:after{     content:'';     position:absolute;     width:100%;     height:100%; } div:before{     background: red;     box-shadow: 0 0 140px 64px red;     z-index:2;     top: -96%; left: -72%;     opacity: 0.8; } div:after { background: white; z-index: 3; bottom: -96%; right: -72%; box-shadow: 0 0 140px 64px white; opacity: 1; border-radius: 100%; } 

Method 2:

enter image description here

div{ overflow: hidden; background: #f06; background: linear-gradient(45deg, #fff722, #ff26f9); min-height: 100%; width:256px; height:256px;   position:relative;     z-index:1; }  div:before,div:after{     content:'';     position:absolute;     width:100%;     height:100%; } div:before{     background: red;     box-shadow: 0 0 140px 64px red;     z-index:2;     top: -96%; left: -72%;     opacity: 0.8; } div:after { background: white; z-index: 3; bottom: -96%; right: -72%; box-shadow: 0 0 140px 64px white; opacity: 1; border-radius: 100%; } 

jsFiddle Demo

Method 3: multiple background:

enter image description here

div{ background: #f06; background: linear-gradient(45deg, #fff722, #ff26f9),linear-gradient(142deg, transparent, white),linear-gradient(108deg, red, transparent); min-height: 100%; width:256px; height:256px;   position:relative;     z-index:1; } 

jsFiddle Demo

Method 4: pseudo element

div{ background: #f06; background: linear-gradient(45deg, #fff722, #ff26f9); min-height: 100%; width:256px; height:256px;   position:relative;     z-index:1; }  div:before,div:after{     content:'';     position:absolute;     width:100%;     height:100%;     opacity: 0.8; } div:before{     background: linear-gradient(108deg, red, transparent);     z-index:2;     top:0;     left:0; } div:after{     background: linear-gradient(142deg, transparent, white);     z-index:3;     bottom:0;     right:0; } 

the markup:

<div></div> 

jsFiddle Demo

Method 5:

div{ overflow: hidden; background: #f06; background: linear-gradient(45deg, #fff722, #ff26f9); min-height: 100%; width:256px; height:256px;   position:relative;     z-index:1; }  div:before,div:after{     content:'';     position:absolute;     width:100%;     height:100%; } div:before{     background: linear-gradient(108deg, red, transparent);     z-index:2;     top:0;     left:0;     opacity: 0.8; } div:after { background: white; z-index: 3; bottom: -96%; right: -72%; box-shadow: 0 0 110px 54px white; opacity: 1; border-radius: 100%; } 

jsFiddle Demo

Update: many thanks to Ana-Maria Tudor <3

body{ position:fixed; top:0; right:0; bottom:0; left:0; }  body:before {   content: '';   position:absolute;   top:0;   right:0;   bottom:0;   left:0;   display: block;   width: 100%;   height: 600px;   border-radius: 0%;   background:     radial-gradient(circle at 50% 0,           rgba(255,0,0,.5), rgba(255,0,0,0) 70.71%),      radial-gradient(circle at 6.7% 75%,           rgba(0,0,255,.5), rgba(0,0,255,0) 70.71%),      radial-gradient(circle at 93.3% 75%,           rgba(0,255,0,.5), rgba(0,255,0,0) 70.71%); } 

jsFiddle Demo

like image 67
Gildas.Tambo Avatar answered Nov 12 '22 20:11

Gildas.Tambo