0

I am wondering if it is possible to do something like this with css gradients alone:

http://postimg.org/image/nxciwsv4f/

In this example the center orange would fade into grey in all directions. The black rectangle represents a div.

I couldn't find this on w3 schools, although there were various other gradient-related capabilities.

MujtabaFR
  • 5,956
  • 6
  • 40
  • 66
Anon Omus
  • 383
  • 4
  • 12
  • 25
  • 1
    w3schools isn't a great reference source... [You may want to try the Mozilla Developer Network](https://developer.mozilla.org/en-US/docs/Web/Guide/CSS/Using_CSS_gradients) – apaul Apr 21 '14 at 20:36
  • If you do not look for compatibilit with older browser, you may use box-shadow and a pseudo to draw it easily ... when you know the size http://jsfiddle.net/fLKuH/2/ – G-Cyrillus Apr 21 '14 at 21:04

1 Answers1

5

Isn't that exactly what radial gradient is all about?

background: #eded2f; /* Old browsers */
background: -moz-radial-gradient(center, ellipse cover,  #eded2f 0%, #474919 100%); /* FF3.6+ */
background: -webkit-gradient(radial, center center, 0px, center center, 100%, color-stop(0%,#eded2f), color-stop(100%,#474919)); /* Chrome,Safari4+ */
background: -webkit-radial-gradient(center, ellipse cover,  #eded2f 0%,#474919 100%); /* Chrome10+,Safari5.1+ */
background: -o-radial-gradient(center, ellipse cover,  #eded2f 0%,#474919 100%); /* Opera 12+ */
background: -ms-radial-gradient(center, ellipse cover,  #eded2f 0%,#474919 100%); /* IE10+ */
background: radial-gradient(ellipse at center,  #eded2f 0%,#474919 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#eded2f', endColorstr='#474919',GradientType=1 ); /* IE6-9 fallback on horizontal gradient */

See fiddle: http://jsfiddle.net/fLKuH/

MarcinJuraszek
  • 124,003
  • 15
  • 196
  • 263