diff options
author | Peter Bengtsson <mail@peterbe.com> | 2020-12-08 14:40:17 -0500 |
---|---|---|
committer | Peter Bengtsson <mail@peterbe.com> | 2020-12-08 14:40:17 -0500 |
commit | 33058f2b292b3a581333bdfb21b8f671898c5060 (patch) | |
tree | 51c3e392513ec574331b2d3f85c394445ea803c6 /files/zh-cn/web/css/gradient | |
parent | 8b66d724f7caf0157093fb09cfec8fbd0c6ad50a (diff) | |
download | translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.gz translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.bz2 translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.zip |
initial commit
Diffstat (limited to 'files/zh-cn/web/css/gradient')
-rw-r--r-- | files/zh-cn/web/css/gradient/index.html | 127 |
1 files changed, 127 insertions, 0 deletions
diff --git a/files/zh-cn/web/css/gradient/index.html b/files/zh-cn/web/css/gradient/index.html new file mode 100644 index 0000000000..8cb033cb7b --- /dev/null +++ b/files/zh-cn/web/css/gradient/index.html @@ -0,0 +1,127 @@ +--- +title: <gradient> +slug: Web/CSS/gradient +translation_of: Web/CSS/gradient +--- +<div>{{CSSRef}}</div> + +<div><strong><code><gradient></code></strong> 是一种{{cssxref("<image>")}}CSS数据类型的子类型,用于表现两种或多种颜色的过渡转变。</div> + +<div><strong><code><gradient></code></strong> <a href="/en-US/docs/CSS/image#no_intrinsic">没有内在尺寸</a>;即,不具备固有或首选的尺寸,也不具备首选的比率。其实际的大小取决于其填充元素的大小。</div> + +<h2 id="语法">语法</h2> + +<h3 id="渐变函数">渐变函数</h3> + +<p><strong><code><gradient></code></strong> 数据类型由下列函数定义。</p> + +<div id="linear-gradient"> +<h4 id="线形渐变"><strong>线形渐变</strong></h4> + +<p>颜色值沿着一条隐式的直线逐渐过渡。由{{cssxref("linear-gradient", "linear-gradient()")}}产生。</p> + +<div class="hidden"> +<pre class="brush: html"><div class="linear-gradient">Linear gradient</div> +</pre> + +<pre class="brush: css">div { + width: 240px; + height: 80px; +}</pre> +</div> + +<pre class="brush: css">.linear-gradient { + background: linear-gradient(to right, + red, orange, yellow, green, blue, indigo, violet); +}</pre> + +<p>{{EmbedLiveSample('linear-gradient', 240, 80)}}</p> +</div> + +<div id="radial-gradient"> +<h4 id="径向渐变">径向渐变</h4> + +<p>颜色值由一个中心点(原点)向外扩散并逐渐过渡到其他颜色值。由{{cssxref("radial-gradient", "radial-gradient()")}}函数产生。</p> + +<div class="hidden"> +<pre class="brush: html"><div class="radial-gradient">Radial gradient</div> +</pre> + +<pre class="brush: css">div { + width: 240px; + height: 80px; +}</pre> +</div> + +<pre class="brush: css">.radial-gradient { + background: radial-gradient(red, yellow, rgb(30, 144, 255)); +} +</pre> + +<p>{{EmbedLiveSample('radial-gradient', 240, 80)}}</p> +</div> + +<div id="repeating-gradient"> +<h4 id="重复渐变">重复渐变</h4> + +<p>重复多次渐变图案直到足够填满指定元素。由 {{cssxref("repeating-linear-gradient", "repeating-linear-gradient()")}}和{{cssxref("repeating-radial-gradient", "repeating-radial-gradient()")}}函数产生。</p> + +<div class="hidden"> +<pre class="brush: html"><div class="linear-repeat">Repeating linear gradient</div> +<br> +<div class="radial-repeat">Repeating radial gradient</div> +</pre> + +<pre class="brush: css">div { + width: 240px; + height: 80px; +}</pre> +</div> + +<pre class="brush: css">.linear-repeat { + background: repeating-linear-gradient(to top left, + lightpink, lightpink 5px, white 5px, white 10px); +} + +.radial-repeat { + background: repeating-radial-gradient(powderblue, powderblue 8px, white 8px, white 16px); +}</pre> + +<p>{{EmbedLiveSample('repeating-gradient', 220, 180)}}</p> +</div> + +<h2 id="插值">插值</h2> + +<p>与其他的颜色插值一样,颜色渐变也通过Alpha预乘(alpha-permultiplied)计算得到结果。这样避免了因为颜色和透明度转变带来的不可预见的灰色阴影。(在使用<a href="/en-US/docs/Web/CSS/color_value#transparent_keyword">transparent keyword</a>时,敬请注意一些没有使用这种计算方式的旧浏览器。)</p> + +<h2 id="规格"><font face="x-locale-heading-primary, zillaslab, Palatino, Palatino Linotype, x-locale-heading-secondary, serif"><span style="font-size: 40px;"><strong>规格</strong></span></font></h2> + +<table class="standard-table"> + <thead> + <tr> + <th>规格</th> + <th>状态</th> + <th>评价</th> + </tr> + </thead> + <tbody> + <tr> + <td>{{SpecName('CSS3 Images', '#gradients', '<gradient>')}}</td> + <td>{{Spec2('CSS3 Images')}}</td> + <td>初始定义。</td> + </tr> + </tbody> +</table> + +<h2 id="浏览器兼容性"><font face="x-locale-heading-primary, zillaslab, Palatino, Palatino Linotype, x-locale-heading-secondary, serif"><span style="font-size: 40px;"><strong>浏览器兼容性</strong></span></font></h2> + +<p>每一种渐变都有不同的兼容性,敬请查阅特定渐变的相关文献与资料以获取更多信息。</p> + +<h2 id="See_also">See also</h2> + +<ul> + <li><a href="/en-US/docs/CSS/Using_CSS_gradients" title="Using gradients">Using CSS gradients</a>,</li> + <li>渐变方程:{{cssxref("<gradient>")}}, {{cssxref("linear-gradient", "linear-gradient()")}}, {{cssxref("radial-gradient", "radial-gradient()")}}, {{cssxref("repeating-linear-gradient", "repeating-linear-gradient()")}}, {{cssxref("repeating-radial-gradient", "repeating-radial-gradient()")}};</li> +</ul> + +<p> </p> |