简体   繁体   中英

CSS linear gradient from center

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.

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/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM