首页  >  文章  >  web前端  >  CSS的取值radial-gradient()_html/css_WEB-ITnose

CSS的取值radial-gradient()_html/css_WEB-ITnose

WBOY
WBOY原创
2016-06-24 11:28:081167浏览

语法结构:

<radial-gradient>:radial-gradient([ <position>,]? [ [ <shape> || <size> ] | <shape-size>{2},]? <color-stop>[, <color-stop>]+);<position>:[ <length>① | <percentage>① | left | center① | right ]? [ <length>② | <percentage>② | top | center② | bottom ]?<shape>:circle | ellipse<size>:closest-side | closest-corner | farthest-side | farthest-corner | contain | cover<shape-size>:<length> | <percentage> <color-stop>:<color> [ <length> | <percentage> ]?

取值:

①:用百分比指定径向渐变圆心的横坐标值。可以为负值。 
①:用长度值指定径向渐变圆心的横坐标值。可以为负值。 
left:设置左边为径向渐变圆心的横坐标值。 
center①:设置中间为径向渐变圆心的横坐标值。 
right:设置右边为径向渐变圆心的横坐标值。 
②:用百分比指定径向渐变圆心的纵坐标值。可以为负值。 
②:用长度值指定径向渐变圆心的纵坐标值。可以为负值。 
top:设置顶部为径向渐变圆心的纵坐标值。 
center②:设置中间为径向渐变圆心的纵坐标值。 
bottom:设置底部为径向渐变圆心的纵坐标值。 
:指定渐变的起止颜色。 

circle:指定圆形的径向渐变。 
ellipse:指定椭圆形的径向渐变。写本文档时Chrome,Safari尚不支持该参数值。 

closest-side:指定径向渐变的半径长度为从圆心到离圆心最近的边。 
closest-corner:指定径向渐变的半径长度为从圆心到离圆心最近的角。 
farthest-side:指定径向渐变的半径长度为从圆心到离圆心最远的边。 
farthest-corner:指定径向渐变的半径长度为从圆心到离圆心最远的角。 
contain:包含,指定径向渐变的半径长度为从圆心到离圆心最近的点。类同于closest-side。 
cover:覆盖,指定径向渐变的半径长度为从圆心到离圆心最远的点。类同于farthest-corner 

写本文档时Firefox尚不支持。 
:用百分比指定径向渐变的横向或纵向直径长度,并根据横向和纵向的直径来确定是圆或椭圆。不允许负值。 
:用长度值指定径向渐变的横向或纵向直径长度,并根据横向和纵向的直径来确定是圆或椭圆。不允许负值。 

:指定颜色。 
:用长度值指定起止色位置,不允许负值。 
:用百分比指定起止色位置。 
浏览器支持:
主流浏览器都支持此属性。
1.IE9和IE9以下浏览器不支持此属性。
2.Opera11.60以下不支持此属性。
3.IE以外浏览器都需要使用各自的浏览器兼容写法。
实例代码:

<!DOCTYPE html><html><head><meta charset=" utf-8"><meta name="author" content="http://www.softwhy.com/" /><title>蚂蚁部落</title><style type="text/css">div{  width:200px;  height:100px;  margin-top:10px;  border:1px solid #ddd;}.test{  background:-moz-radial-gradient(center center, circle, #f00, #ff0, #080);  background:-webkit-radial-gradient(center center, circle, #f00, #ff0, #080);  background:-o-radial-gradient(center center, circle, #f00, #ff0, #080);  background:-ms-radial-gradient(center center, circle, #f00, #ff0, #080);  background:radial-gradient(center center, circle, #f00, #ff0, #080);}.test2{  background:-moz-radial-gradient(circle contain, #f00, #ff0, #080);  background:-webkit-radial-gradient(circle contain, #f00, #ff0, #080);  background:-o-radial-gradient(circle contain, #f00, #ff0, #080);  background:-ms-radial-gradient(circle contain, #f00, #ff0, #080);  background:radial-gradient(circle contain, #f00, #ff0, #080);}.test3{  background:-moz-radial-gradient(left top, cover, #f00 20%, #ff0 50%, #080 80%);  background:-webkit-radial-gradient(left top, cover, #f00 20%, #ff0 50%, #080 80%);  background:-o-radial-gradient(left top, cover, #f00 20%, #ff0 50%, #080 80%);  background:-ms-radial-gradient(left top, cover, #f00 20%, #ff0 50%, #080 80%);  background:radial-gradient(left top, cover, #f00 20%, #ff0 50%, #080 80%);}.test4{  background:-moz-radial-gradient(90% 50px, closest-side, #f00, #ff0, #080);  background:-webkit-radial-gradient(90% 50px, closest-side, #f00, #ff0, #080);  background:-o-radial-gradient(90% 50px, closest-side, #f00, #ff0, #080);  background:-ms-radial-gradient(90% 50px, closest-side, #f00, #ff0, #080);  background:radial-gradient(90% 50px, closest-side, #f00, #ff0, #080);}</style></head><body><div class="test"></div><div class="test2"></div><div class="test3"></div><div class="test4"></div></body></html>

原文地址是:http://www.softwhy.com/forum.php?mod=viewthread&tid=1147

声明:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn