Heim > Artikel > Web-Frontend > CSS的取值radial-gradient()_html/css_WEB-ITnose
语法结构:
<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