Questions tagged [radial-gradients]

A linear interpolation between two or more colors based on the distance from the center of a circle or ellipse. In radial gradients, the colors emerge from a single point and smoothly spread outward in a circular or elliptical shape unlike in linear gradients where it is from one end to another. Use this tag for any question pertaining to creation or usage of radial gradients.

Radial gradients are a linear interpolation between two or more colors based on the distance from the center of a circle or ellipse.

In radial gradients, the colors emerge from a single point and smoothly spread outward in a circular or elliptical shape unlike in linear gradients where it is from one end to another.

Radial Gradients in CSS

In CSS, a radial gradient can be created using the below syntax: (Source - W3C)

radial-gradient() = radial-gradient(
  [ [ circle               || <length> ]                          [ at <position> ]? , |
    [ ellipse              || [ <length> | <percentage> ]{2} ]    [ at <position> ]? , |
    [ [ circle | ellipse ] || <extent-keyword> ]                  [ at <position> ]? , |
    at <position> ,
  ]?
  <color-stop> [ , <color-stop> ]+
)
<extent-keyword> = closest-corner | closest-side | farthest-corner | farthest-side

Here is a sample rainbow generated using radial gradients:

.rainbow {
  height: 25vw;
  width: 50vw;
  background: -webkit-radial-gradient(50% 110%, ellipse, white 35%, violet 35%, violet 40%, indigo 40%, indigo 45%, blue 45%, blue 50%, green 50%, green 55%, yellow 55%, yellow 60%, orange 60%, orange 65%, red 65%, red 70%, white 70%);
  background: -moz-radial-gradient(50% 110%, ellipse, white 35%, violet 35%, violet 40%, indigo 40%, indigo 45%, blue 45%, blue 50%, green 50%, green 55%, yellow 55%, yellow 60%, orange 60%, orange 65%, red 65%, red 70%, white 70%);
  background: radial-gradient(ellipse at 50% 110%, white 35%, violet 35%, violet 40%, indigo 40%, indigo 45%, blue 45%, blue 50%, green 50%, green 55%, yellow 55%, yellow 60%, orange 60%, orange 65%, red 65%, red 70%, white 70%);
}

enter image description here

Useful Links/References:

353 questions
8
votes
1 answer

Cairo Radial Gradient

I'm using a radial gradient in Cairo, but I'm not getting the expected results. The radial gradient I'm getting is much less fuzzy than I'd expect and I can't seem to fiddle with the color stops in order to get the desired results. Here is the…
Q2Ftb3k
  • 678
  • 3
  • 9
  • 18
8
votes
2 answers

Drawing Spheres with RadialGradientBrush

I'm trying to draw spherical pieces for a game, in WPF. Pieces are drawns as Elipses with RadialGradientBrushs. As you can see below, my black pieces look fantastic, but it is hard to get the white ones having any depth without making them look…
Frames Catherine White
  • 27,368
  • 21
  • 87
  • 137
7
votes
1 answer

Make a radial gradients radius 200px

How would I make the radius 200px in width and height? I've read that this can be done in pixel units, but every attempt has failed. background-image: -webkit-radial-gradient(75% 100%, circle farthest-corner, #ffffff, #ff7ae9 33%); background-image:…
android.nick
  • 11,069
  • 23
  • 77
  • 112
7
votes
1 answer

createRadialGradient and transparency

I'm playing around with createRadialGradient() on HTML5 canvas. It works like a charm, except when I'm trying to implement (semi-)transparency. I made this jsFiddle to make things hopefully clearer: http://jsfiddle.net/rfLf6/1/. function circle(x,…
pimvdb
  • 151,816
  • 78
  • 307
  • 352
7
votes
3 answers

Creating a droplet like border effect in css

I created this border design in Photoshop and was wondering if anyone could give me some guidance with how to recreate this using css.
cheese12345
  • 573
  • 1
  • 5
  • 15
7
votes
2 answers

Why CSS and SVG radial gradients do not match?

The outcome of the gradients should not be the same? Why are they so different... Am I missing something? DEMOSTRATION SVG
rafaelcastrocouto
  • 11,781
  • 3
  • 38
  • 63
7
votes
1 answer

Radial box-shadow on element

Is there a way to create a box-shadow that radiates in a circle from a rectangular div element? So like a regular shadow, except rounded.
Alfred Xing
  • 4,406
  • 2
  • 23
  • 34
6
votes
3 answers

firefox and radialgradient (using html5 canvas)

For some reason, my firefox doesn´t show radial gradient when using a Canvas, does anyone know why? (I don´t have this problem on other computers) here is some of the code I´m using: var canvas = document.getElementById ( "layer2" ) ; var context =…
Camilo Barraza
  • 195
  • 1
  • 9
6
votes
1 answer

Mask Image, create rectangle from multiple gradients

I have a radial gradient that used as a mask-image "fades" an image in to the background-color behind the image. mask-image: radial-gradient(ellipse at center, rgba(255,255,255,1) 1%,rgba(255,255,255,1) 50%,rgba(255,255,255,0)…
John
  • 1
  • 13
  • 98
  • 177
6
votes
1 answer

How to control height of ellipse in radial gradient

I am trying to use radial gradient for my background and below is the code. div { width: 778px; height: 100px; background: radial-gradient(ellipse at top center, green, yellow 229px); background-size: 100% 100%; background-position:…
satish kumar V
  • 1,695
  • 6
  • 33
  • 47
6
votes
1 answer

Why doesn't this radial-gradient complete the circle?

I'm trying to use a radial gradient to create a border within circle elements that are radio buttons. The basic CSS is shown below. I cannot figure out why the red gradient does not circle the entire circumference of the circles. As the white…
mbomb007
  • 3,788
  • 3
  • 39
  • 68
6
votes
1 answer

How can I animate a gradient with large pixels?

I am working on a project where I would like to have darkness covering the screen and the character glowing in the darkness. I tried to animate the scene then draw darkness over it using this code: var canvas = document.getElementById('canvas'); var…
Other Me
  • 498
  • 2
  • 7
6
votes
1 answer

Swift combine radial gradients

Imagine a couple radial gradients with some radius scattered in a plane. The centers of the gradients arranged like this, for example: A D B C E F Now coming out of each of these centers is a radial gradient with some radius. I know…
IHaveAQuestion
  • 789
  • 8
  • 26
6
votes
1 answer

CSS Single Div Drawing - Shapes

I'm trying to draw using CSS gradients and a single div. Unfortunately, there is no enough information about it so I needed to learn it myself by reading other people's code. Here are some…
StyleSh1t
  • 717
  • 1
  • 12
  • 18
6
votes
2 answers

CSS: Slice radial-gradient 50% on bottom for another similar radial-gradient?

If I have this: https://codepen.io/anon/pen/MveydB body { width: 100vh; height: 100vh; background-image: radial-gradient(circle closest-side, #00bffb, rgba(0, 0, 0, 1)); } How I can have something like this instead?: It's impossible to edit…
DIES
  • 345
  • 5
  • 14
1
2
3
23 24