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
4
votes
4 answers

Radial gradient in shape of ring in CSS

I would like to create "ring" shape with specified thickness (in px) with radial gradient. Desired result is: However, I don't know how to specify thickness in pixels and ensure that the color transition is smooth from green to transparent (not cut…
Michal
  • 1,755
  • 3
  • 21
  • 53
4
votes
1 answer

How does this scrolling shadows CSS-magic work?

I found this infamous article from 2012. It details how to create scrolling shadows and still works beautifully but I really want to understand the solution and I can't seem to find the necessary information online. Here is the minified code…
4
votes
2 answers

Why is webkit radial gradient not working in Safari?

This is working in Chrome but not in Safari: background: -webkit-radial-gradient(center, ellipse cover, #fdfdfd, #d3d3d3); How can I fix it for Safari?
coure2011
  • 40,286
  • 83
  • 216
  • 349
4
votes
1 answer

Does the SVG filter feFlood 'flood-color' property support gradient as input?

I am experimenting with SVG filters while trying to create a vignette effect. I've found a snippet in an old repo where the author did it like this, but feFlood doesn't pick up the filter for me. I tried flood-color="url(#gradient_toaster)" too but…
Edmond Tamas
  • 3,148
  • 9
  • 44
  • 89
4
votes
3 answers

How can I alter the curve of a radial gradient in CSS?

I'm trying to achieve this gradient. What I don't understand is the curvature of it and I'm not sure on how to replicate it: What I have so far: and my code for the gradient: radial-gradient(at top left,#629a92 36%,#02d2a0 67%, #fff…
nyphur
  • 2,404
  • 2
  • 24
  • 48
4
votes
4 answers

CSS - Rotate radial-gradient

I have got a
with radial-gradient, but it is at a wrong angle. Changing the angle of simple linear-gradient is easy, but it has multiple gradients. I can't add 90deg at the start, because it doesn't work. Below is my gradient. The waves are…
Kacper G.
  • 662
  • 8
  • 30
4
votes
1 answer

Radial gradient - procedural texture for cocos2d-x v3.15+

In cocos2d-x there is already a LayerRadialGradient. Works well, but I've other shaders running on the my game scene, so performance in a problem now. It's using a shader. I want to replace it with just a Sprite with generated radial gradient…
4
votes
2 answers

Show progress half way in li using css

Something like below: My Less looks as below at the moment. /*progressbar*/ .progressbar { margin-bottom: 30px; margin-top: 10px; counter-reset: step; clear: both; } .progressbar li { font-size: 12px; width: 24%; …
vini
  • 4,657
  • 24
  • 82
  • 170
4
votes
1 answer

CABasicAnimation creates empty default value copy of CALayer

I have a custom CALayer that draws radial gradients. It works great except during animation. It seems that each iteration of CABasicAnimation creates a new copy of the CALayer subclass with empty, default values for the properties: In the…
4
votes
2 answers

CSS radial gradient drop shadow - reversed

Have some pre-existing code from a Wordpress template that draws an ellipse drop shadow. The shadow radiates downward in an ellipse. Only the bottom half of the ellipse is visible, creating a bottom shadow effect. I simply want to "reverse" the…
digitalJE5U5
  • 113
  • 1
  • 1
  • 5
4
votes
1 answer

Making Glowing Background with CSS only

I want to create this background in CSS only. I want to do it with CSS to avoid responsive issues.
Mosh
  • 101
  • 2
  • 9
4
votes
2 answers

Multiple background images, gradient and image, matching scale of image

I have a background made up of an image and a gradient. http://codepen.io/anon/pen/RWrKGv I'm using the following CSS: .row { display: block; width: 50%; min-height: 150px; min-height: 750px; background: -webkit-radial-gradient( 50% 50%,…
Finnnn
  • 3,530
  • 6
  • 46
  • 69
4
votes
2 answers

How to add shadow to reverse c radial gradient only at the edges?

I am new to this topic and have not found anywhere how to apply shadow to the reverse C type corners only. Below is the link of Example image for which I am trying to add shadow only to the corners Below is the code which I have used to achieve…
4
votes
1 answer

svg transparent radial gradient in safari not working

I have a SVG radial gradient that works in Chrome, Firefox and even Internet Explorer but does not work in Safari. Any idea how to get this to work in Safari? Here is the codepen: http://codepen.io/fractorr/pen/OVaYvV
Trevor Orr
  • 927
  • 1
  • 14
  • 31
4
votes
2 answers

Dynamic stamp effect using radial-gradient

This example (not my code): http://codepen.io/mohitmanuja/pen/odxic Show how to use radial-gradient to apply a nice stamp edges effect. HTML: body { padding: 100px; background: #aaa; } .stamp { width: 184px; height: 184px; …
Nizarnav
  • 167
  • 6