简体   繁体   English

从中心开始的CSS线性渐变

[英]CSS linear gradient from center

I am wondering if it is possible to do something like this with css gradients alone: 我想知道是否可以单独使用css渐变来做这样的事情:

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

In this example the center orange would fade into grey in all directions. 在此示例中,中心橙色将在所有方向上逐渐变为灰色。 The black rectangle represents a div. 黑色矩形代表div。

I couldn't find this on w3 schools, although there were various other gradient-related capabilities. 尽管还有其他与梯度相关的功能,但在w3学校中我找不到。

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/ 参见小提琴: http : //jsfiddle.net/fLKuH/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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