size 参数定义了渐变的大小。它可以是以下四个值:
{C}Ø {C}{C}closest-side
{C}Ø {C}{C}farthest-side
{C}Ø {C}{C}closest-corner
{C}Ø {C}{C}farthest-corner
实例:带有不同尺寸大小关键字的径向渐变
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<style>
#grad1 {
height: 150px;
width: 150px;
background: -webkit-radial-gradient(60% 55%, closest-side,blue,green,yellow,black); /* Safari 5.1 - 6.0 */
background: -o-radial-gradient(60% 55%, closest-side,blue,green,yellow,black); /* Opera 11.6 - 12.0 */
background: -moz-radial-gradient(60% 55%, closest-side,blue,green,yellow,black); /* Firefox 3.6 - 15 */
background: radial-gradient(60% 55%, closest-side,blue,green,yellow,black); /* 标准的语法(必须放在最后) */
}
#grad2 {
height: 150px;
width: 150px;
background: -webkit-radial-gradient(60% 55%, farthest-side,blue,green,yellow,black); /* Safari 5.1 - 6.0 */
background: -o-radial-gradient(60% 55%, farthest-side,blue,green,yellow,black); /* Opera 11.6 - 12.0 */
background: -moz-radial-gradient(60% 55%, farthest-side,blue,green,yellow,black); /* Firefox 3.6 - 15 */
background: radial-gradient(60% 55%, farthest-side,blue,green,yellow,black); /* 标准的语法(必须放在最后) */
}
#grad3 {
height: 150px;
width: 150px;
background: -webkit-radial-gradient(60% 55%, closest-corner,blue,green,yellow,black); /* Safari 5.1 - 6.0 */
background: -o-radial-gradient(60% 55%, closest-corner,blue,green,yellow,black); /* Opera 11.6 - 12.0 */
background: -moz-radial-gradient(60% 55%, closest-corner,blue,green,yellow,black); /* Firefox 3.6 - 15 */
background: radial-gradient(60% 55%, closest-corner,blue,green,yellow,black); /* 标准的语法(必须放在最后) */
}
#grad4 {
height: 150px;
width: 150px;
background: -webkit-radial-gradient(60% 55%, farthest-corner,blue,green,yellow,black); /* Safari 5.1 - 6.0 */
background: -o-radial-gradient(60% 55%, farthest-corner,blue,green,yellow,black); /* Opera 11.6 - 12.0 */
background: -moz-radial-gradient(60% 55%, farthest-corner,blue,green,yellow,black); /* Firefox 3.6 - 15 */
background: radial-gradient(60% 55%, farthest-corner,blue,green,yellow,black); /* 标准的语法(必须放在最后) */
}
</style>
</head>
<body>
<h3>径向渐变 - 不同尺寸大小关键字的使用</h3>
<p><strong>closest-side:</strong></p>
<div id="grad1"></div>
<p><strong>farthest-side:</strong></p>
<div id="grad2"></div>
<p><strong>closest-corner:</strong></p>
<div id="grad3"></div>
<p><strong>farthest-corner(默认):</strong></p>
<div id="grad4"></div>
<p><strong>注意:</strong> Internet Explorer 9 及之前的版本不支持渐变。</p>
</body>
</html>
<view class='c1'>
closest-side
</view>
<view class='c2'>
farthest-side
</view>
<view class='c3'>
closest-corner
</view>
<view class='c4'>
farthest-corner(默认)
</view>
.c1{
margin: 10px;
padding: 20px;
height: 150px;
width: 150px;
background: radial-gradient( closest-side,blue,green,yellow,black); /* 标准的语法(必须放在最后) */
}
.c2{
margin: 10px;
padding: 20px;
height: 150px;
width: 150px;
background: radial-gradient(farthest-side,blue,green,yellow,black); /* 标准的语法(必须放在最后) */
}
.c3{
margin: 10px;
padding: 20px;
height: 150px;
width: 150px;
background: radial-gradient(closest-corner,blue,green,yellow,black); /* 标准的语法(必须放在最后) */
}
.c4{
margin: 10px;
padding: 20px;
height: 150px;
width: 150px;
background: radial-gradient(farthest-corner,blue,green,yellow,black); /* 标准的语法(必须放在最后) */
}