Template:Radial-gradient/doc
此頁面是Template:Radial-gradient的Template文档。 此頁面可能包含了模板的使用說明、分類和其他内容。 |
此模板的文档不存在、不全面或不能详细描述其功能及/或其代码中的参数。请帮助扩充并改进其文档。 |
This template creates a radial gradient background. This currently works in Firefox (3.6 and up), Opera (12.0 and up), Safari (5.1 and up), Google Chrome (10 and up) and Internet Explorer 10.
用途
Use within a CSS style tag. The template uses the background-image property.
<div style="{{radial-gradient | position | shape [size] | #color [stop], #color [stop][, #color [stop], ...] }}">Lorem ipsum...</div>
- position – Mandatrory. Specify the X and Y position of the center of the gradient. This can be any valid CSS position value.
- shape – Mandatory. Specify the shape of the gradient using keywords or CSS size values. Valid keywords are:
- ellipse
- circle
- size – Optional. Specify the size of the radial using keywords or CSS size values.
- farthest-corner (or cover); Extends the radial to the farthest element corner, ensuring the gradient covers the entire element. This is the default.
- closest-corner; Extends the radial to the closest corner.
- farthest-side; Extends the radial to the farthest edge.
- closest-side (or contain); Extends the radial to the closest edge, ensuring the gradient does not extend beyond the element's borders.
Valid keywords are:
- color – The first two colors are mandatory. You can define any number of additional colors, separated with commas.
- stop – Optional. You can specify a stop position for each color using a percentage (e.g. 45%) or pixels (e.g. 60px).
^note 1 : Firefox does not yet support explicit size values, only keywords.
技术备忘
The template does not assign a default background-color, and therefor does not provide an automatic fallback for browsers that do not support gradients. To provide a fallback, always specify a background color in front of the template.
This template uses the new CSS3 properties for radial gradients: -moz-radial-gradient, -ms-radial-gradient, -o-radial-gradient, -webkit-radial-gradient and radial-gradient.
示例
- <div style="{{radial-gradient|100px center|ellipse cover|#ffdddd, #ddddff}}">Lorem ipsum...</div> will produce
- <div style="{{radial-gradient|center|ellipse contain|#ffdddd, #ddffdd 50%, #ddddff}}">Lorem ipsum...</div> will produce
- <div style="{{radial-gradient|top|circle|#ffdddd, #ddddff}}">Lorem ipsum...</div> will produce
注意事项
Above examples use contrasting colors to show the effect more clearly. It is best to use subtle differences in color to enhance the appearance, rather than radically change it. This also minimizes the effects between browsers that do and do not support gradients.
参见
- {{linear-gradient}}
- {{border-radius}}
- {{box-shadow}}