aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/css/transition-timing-function
diff options
context:
space:
mode:
authorPeter Bengtsson <mail@peterbe.com>2020-12-08 14:40:17 -0500
committerPeter Bengtsson <mail@peterbe.com>2020-12-08 14:40:17 -0500
commit33058f2b292b3a581333bdfb21b8f671898c5060 (patch)
tree51c3e392513ec574331b2d3f85c394445ea803c6 /files/zh-cn/web/css/transition-timing-function
parent8b66d724f7caf0157093fb09cfec8fbd0c6ad50a (diff)
downloadtranslated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.gz
translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.bz2
translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.zip
initial commit
Diffstat (limited to 'files/zh-cn/web/css/transition-timing-function')
-rw-r--r--files/zh-cn/web/css/transition-timing-function/index.html632
1 files changed, 632 insertions, 0 deletions
diff --git a/files/zh-cn/web/css/transition-timing-function/index.html b/files/zh-cn/web/css/transition-timing-function/index.html
new file mode 100644
index 0000000000..3cceed4dfc
--- /dev/null
+++ b/files/zh-cn/web/css/transition-timing-function/index.html
@@ -0,0 +1,632 @@
+---
+title: transition-timing-function
+slug: Web/CSS/transition-timing-function
+translation_of: Web/CSS/transition-timing-function
+---
+<p>{{ CSSRef() }}{{SeeCompatTable}}</p>
+
+<h2 id="概述">概述</h2>
+
+<p>CSS属性受到 <a href="/en-US/docs/CSS/Tutorials/Using_CSS_transitions" title="en/CSS/CSS transitions">transition effect</a>的影响,会产生不断变化的中间值,而 <a href="/en-US/docs/CSS" title="/en-US/docs/CSS">CSS</a> <code>transition-timing-function</code> 属性用来描述这个中间值是怎样计算的。实质上,通过这个函数会建立一条加速度曲线,因此在整个transition变化过程中,变化速度可以不断改变。</p>
+
+<p>这条加速度曲线被{{cssxref("&lt;timing-function&gt;")}}所定义,之后作用到每个CSS属性的过渡. </p>
+
+<p>你可以规定多个timing function,通过使用 {{ cssxref("transition-property") }}属性,可以根据主列表(transition property的列表)给每个CSS属性应用相应的timing function.如果timing function的个数比主列表中数量少,缺少的值被设置为初始值(ease) 。如果timing function比主列表要多,timing function函数列表会被截断至合适的大小。这两种情况下声明的CSS属性都是有效的。</p>
+
+<p>{{cssinfo}}</p>
+
+<h2 id="语法">语法</h2>
+
+<pre class="twopartsyntaxbox"><a href="/en-US/docs/CSS/Value_definition_syntax" title="CSS/Value_definition_syntax">Formal syntax</a>: {{csssyntax("transition-timing-function")}}
+</pre>
+
+<pre>transition-timing-function: ease
+transition-timing-function: ease-in
+transition-timing-function: ease-out
+transition-timing-function: ease-in-out
+transition-timing-function: linear
+transition-timing-function: cubic-bezier(0.1, 0.7, 1.0, 0.1)
+transition-timing-function: step-start
+transition-timing-function: step-end
+transition-timing-function: steps(4, end)
+
+transition-timing-function: ease, step-start, cubic-bezier(0.1, 0.7, 1.0, 0.1)
+
+transition-timing-function: inherit
+</pre>
+
+<h3 id="值">值</h3>
+
+<dl>
+ <dt><code>&lt;timing-function&gt;</code></dt>
+ <dd>通过{{ cssxref("transition-property") }}中定义被过渡属性,每个 {{cssxref("&lt;timing-function&gt;")}}的值代表与这个属性相对应的timing function.</dd>
+</dl>
+
+<h2 id="示例">示例</h2>
+
+<div>
+<div id="ttf_ease">
+<p><code>transition-timing-function: ease</code></p>
+
+<div style="display: none;">
+<pre class="brush:html"> &lt;div class="parent"&gt;
+ &lt;div class="box"&gt;Lorem&lt;/div&gt;
+&lt;/div&gt;
+ </pre>
+
+<pre class="brush:css;">.parent { width: 250px; height:125px;}
+.box {
+ width: 100px;
+ height: 100px;
+ background-color: red;
+ font-size: 20px;
+ left: 0px;
+ top: 0px;
+ position:absolute;
+ -webkit-transition-property: width height background-color font-size left top color;
+ -webkit-transition-duration:2s;
+ -webkit-transition-timing-function: ease;
+ transition-property: width height background-color font-size left top color;
+ transition-duration:2s;
+ transition-timing-function: ease;
+}
+.box1{
+ width: 50px;
+ height: 50px;
+ background-color: blue;
+ color: yellow;
+ font-size: 18px;
+ left: 150px;
+ top:25px;
+ position:absolute;
+ -webkit-transition-property: width height background-color font-size left top color;
+ -webkit-transition-duration:2s;
+ -webkit-transition-timing-function: ease;
+ transition-property: width height background-color font-size left top color;
+ transition-duration:2s;
+ transition-timing-function: ease;
+}
+</pre>
+
+<pre class="brush:js">function updateTransition() {
+ var el = document.querySelector("div.box");
+
+ if (el) {
+ el.className = "box1";
+ } else {
+ el = document.querySelector("div.box1");
+ el.className = "box";
+ }
+
+ return el;
+}
+
+var intervalID = window.setInterval(updateTransition, 7000);
+</pre>
+</div>
+
+<div>{{EmbedLiveSample("ttf_ease",275,150)}}</div>
+</div>
+
+<div id="ttf_easein" style="width: 251px; display: inline-block; margin-right: 1px; margin-bottom: 1px;">
+<p><code>transition-timing-function: ease-in</code></p>
+
+<div style="display: none;">
+<pre class="brush:html"> &lt;div class="parent"&gt;
+ &lt;div class="box"&gt;Lorem&lt;/div&gt;
+&lt;/div&gt;
+ </pre>
+
+<pre class="brush:css;">.parent { width: 250px; height:125px;}
+.box {
+ width: 100px;
+ height: 100px;
+ background-color: red;
+ font-size: 20px;
+ left: 0px;
+ top: 0px;
+ position:absolute;
+ -webkit-transition-property: width height background-color font-size left top color;
+ -webkit-transition-duration:2s;
+ -webkit-transition-timing-function: ease-in;
+ transition-property: width height background-color font-size left top color;
+ transition-duration:2s;
+ transition-timing-function: ease-in;
+}
+.box1{
+ width: 50px;
+ height: 50px;
+ background-color: blue;
+ color: yellow;
+ font-size: 18px;
+ left: 150px;
+ top:25px;
+ position:absolute;
+ -webkit-transition-property: width height background-color font-size left top color;
+ -webkit-transition-duration:2s;
+ -webkit-transition-timing-function: ease-in;
+ transition-property: width height background-color font-size left top color;
+ transition-duration:2s;
+ transition-timing-function: ease-in;
+}
+</pre>
+
+<pre class="brush:js">function updateTransition() {
+ var el = document.querySelector("div.box");
+
+ if (el) {
+ el.className = "box1";
+ } else {
+ el = document.querySelector("div.box1");
+ el.className = "box";
+ }
+
+ return el;
+}
+
+var intervalID = window.setInterval(updateTransition, 7000);
+</pre>
+</div>
+
+<div>{{EmbedLiveSample("ttf_easein",275,150)}}</div>
+</div>
+
+<div id="ttf_easeout" style="width: 251px; display: inline-block; margin-right: 1px; margin-bottom: 1px;">
+<p><code>transition-timing-function: ease-out</code></p>
+
+<div style="display: none;">
+<pre class="brush:html"> &lt;div class="parent"&gt;
+ &lt;div class="box"&gt;Lorem&lt;/div&gt;
+&lt;/div&gt;
+ </pre>
+
+<pre class="brush:css;">.parent { width: 250px; height:125px;}
+.box {
+ width: 100px;
+ height: 100px;
+ background-color: red;
+ font-size: 20px;
+ left: 0px;
+ top: 0px;
+ position:absolute;
+ -webkit-transition-property: width height background-color font-size left top color;
+ -webkit-transition-duration:2s;
+ -webkit-transition-timing-function: ease-out;
+ transition-property: width height background-color font-size left top color;
+ transition-duration:2s;
+ transition-timing-function: ease-out;
+}
+.box1{
+ width: 50px;
+ height: 50px;
+ background-color: blue;
+ color: yellow;
+ font-size: 18px;
+ left: 150px;
+ top:25px;
+ position:absolute;
+ -webkit-transition-property: width height background-color font-size left top color;
+ -webkit-transition-duration:2s;
+ -webkit-transition-timing-function: ease-out;
+ transition-property: width height background-color font-size left top color;
+ transition-duration:2s;
+ transition-timing-function: ease-out;
+}
+</pre>
+
+<pre class="brush:js">function updateTransition() {
+ var el = document.querySelector("div.box");
+
+ if (el) {
+ el.className = "box1";
+ } else {
+ el = document.querySelector("div.box1");
+ el.className = "box";
+ }
+
+ return el;
+}
+
+var intervalID = window.setInterval(updateTransition, 7000);
+</pre>
+</div>
+
+<div>{{EmbedLiveSample("ttf_easeout",275,150)}}</div>
+</div>
+
+<div id="ttf_easeinout" style="width: 251px; display: inline-block; margin-right: 1px; margin-bottom: 1px;">
+<p><code>transition-timing-function: ease-in-out</code></p>
+
+<div style="display: none;">
+<pre class="brush:html"> &lt;div class="parent"&gt;
+ &lt;div class="box"&gt;Lorem&lt;/div&gt;
+&lt;/div&gt;
+ </pre>
+
+<pre class="brush:css;">.parent { width: 250px; height:125px;}
+.box {
+ width: 100px;
+ height: 100px;
+ background-color: red;
+ font-size: 20px;
+ left: 0px;
+ top: 0px;
+ position:absolute;
+ -webkit-transition-property: width height background-color font-size left top color;
+ -webkit-transition-duration:2s;
+ -webkit-transition-timing-function: ease-in-out;
+ transition-property: width height background-color font-size left top color;
+ transition-duration:2s;
+ transition-timing-function: ease-in-out;
+}
+.box1{
+ width: 50px;
+ height: 50px;
+ background-color: blue;
+ color: yellow;
+ font-size: 18px;
+ left: 150px;
+ top:25px;
+ position:absolute;
+ -webkit-transition-property: width height background-color font-size left top color;
+ -webkit-transition-duration:2s;
+ -webkit-transition-timing-function: ease-in-out;
+ transition-property: width height background-color font-size left top color;
+ transition-duration:2s;
+ transition-timing-function: ease-in-out;
+}
+</pre>
+
+<pre class="brush:js">function updateTransition() {
+ var el = document.querySelector("div.box");
+
+ if (el) {
+ el.className = "box1";
+ } else {
+ el = document.querySelector("div.box1");
+ el.className = "box";
+ }
+
+ return el;
+}
+
+var intervalID = window.setInterval(updateTransition, 7000);
+</pre>
+</div>
+
+<div>{{EmbedLiveSample("ttf_easeinout",275,150)}}</div>
+</div>
+</div>
+
+<div id="ttf_linear" style="width: 251px; display: inline-block; margin-right: 1px; margin-bottom: 1px;">
+<p><code>transition-timing-function: linear</code></p>
+
+<div style="display: none;">
+<pre class="brush:html"> &lt;div class="parent"&gt;
+ &lt;div class="box"&gt;Lorem&lt;/div&gt;
+&lt;/div&gt;
+ </pre>
+
+<pre class="brush:css;">.parent { width: 250px; height:125px;}
+.box {
+ width: 100px;
+ height: 100px;
+ background-color: red;
+ font-size: 20px;
+ left: 0px;
+ top: 0px;
+ position:absolute;
+ -webkit-transition-property: width height background-color font-size left top color;
+ -webkit-transition-duration:2s;
+ -webkit-transition-timing-function: linear;
+ transition-property: width height background-color font-size left top color;
+ transition-duration:2s;
+ transition-timing-function: linear;
+}
+.box1{
+ width: 50px;
+ height: 50px;
+ background-color: blue;
+ color: yellow;
+ font-size: 18px;
+ left: 150px;
+ top:25px;
+ position:absolute;
+ -webkit-transition-property: width height background-color font-size left top color;
+ -webkit-transition-duration:2s;
+ -webkit-transition-timing-function: linear;
+ transition-property: width height background-color font-size left top color;
+ transition-duration:2s;
+ transition-timing-function: linear;
+}
+</pre>
+
+<pre class="brush:js">function updateTransition() {
+ var el = document.querySelector("div.box");
+
+ if (el) {
+ el.className = "box1";
+ } else {
+ el = document.querySelector("div.box1");
+ el.className = "box";
+ }
+
+ return el;
+}
+
+var intervalID = window.setInterval(updateTransition, 7000);
+</pre>
+</div>
+
+<div>{{EmbedLiveSample("ttf_linear",275,150)}}</div>
+</div>
+
+<div id="ttf_stepstart" style="width: 251px; display: inline-block; margin-right: 1px; margin-bottom: 1px;">
+<p><code>transition-timing-function: step-start</code></p>
+
+<div style="display: none;">
+<pre class="brush:html"> &lt;div class="parent"&gt;
+ &lt;div class="box"&gt;Lorem&lt;/div&gt;
+&lt;/div&gt;
+ </pre>
+
+<pre class="brush:css;">.parent { width: 250px; height:125px;}
+.box {
+ width: 100px;
+ height: 100px;
+ background-color: red;
+ font-size: 20px;
+ left: 0px;
+ top: 0px;
+ position:absolute;
+ -webkit-transition-property: width height background-color font-size left top color;
+ -webkit-transition-duration:2s;
+ -webkit-transition-timing-function: step-start;
+ transition-property: width height background-color font-size left top color;
+ transition-duration:2s;
+ transition-timing-function: step-start;
+}
+.box1{
+ width: 50px;
+ height: 50px;
+ background-color: blue;
+ color: yellow;
+ font-size: 18px;
+ left: 150px;
+ top:25px;
+ position:absolute;
+ -webkit-transition-property: width height background-color font-size left top color;
+ -webkit-transition-duration:2s;
+ -webkit-transition-timing-function: step-start;
+ transition-property: width height background-color font-size left top color;
+ transition-duration:2s;
+ transition-timing-function: step-start;
+}
+</pre>
+
+<pre class="brush:js">function updateTransition() {
+ var el = document.querySelector("div.box");
+
+ if (el) {
+ el.className = "box1";
+ } else {
+ el = document.querySelector("div.box1");
+ el.className = "box";
+ }
+
+ return el;
+}
+
+var intervalID = window.setInterval(updateTransition, 7000);
+</pre>
+</div>
+
+<div>{{EmbedLiveSample("ttf_stepstart",275,150)}}</div>
+</div>
+
+<div id="ttf_stepend" style="width: 251px; display: inline-block; margin-right: 1px; margin-bottom: 1px;">
+<p><code>transition-timing-function: step-end</code></p>
+
+<div style="display: none;">
+<pre class="brush:html"> &lt;div class="parent"&gt;
+ &lt;div class="box"&gt;Lorem&lt;/div&gt;
+&lt;/div&gt;
+ </pre>
+
+<pre class="brush:css;">.parent { width: 250px; height:125px;}
+.box {
+ width: 100px;
+ height: 100px;
+ background-color: red;
+ font-size: 20px;
+ left: 0px;
+ top: 0px;
+ position:absolute;
+ -webkit-transition-property: width height background-color font-size left top color;
+ -webkit-transition-duration:2s;
+ -webkit-transition-timing-function: step-end;
+ transition-property: width height background-color font-size left top color;
+ transition-duration:2s;
+ transition-timing-function: step-end;
+}
+.box1{
+ width: 50px;
+ height: 50px;
+ background-color: blue;
+ color: yellow;
+ font-size: 18px;
+ left: 150px;
+ top:25px;
+ position:absolute;
+ -webkit-transition-property: width height background-color font-size left top color;
+ -webkit-transition-duration:2s;
+ -webkit-transition-timing-function: step-end;
+ transition-property: width height background-color font-size left top color;
+ transition-duration:2s;
+ transition-timing-function: step-end;
+}
+</pre>
+
+<pre class="brush:js">function updateTransition() {
+ var el = document.querySelector("div.box");
+
+ if (el) {
+ el.className = "box1";
+ } else {
+ el = document.querySelector("div.box1");
+ el.className = "box";
+ }
+
+ return el;
+}
+
+var intervalID = window.setInterval(updateTransition, 7000);
+</pre>
+</div>
+
+<div>{{EmbedLiveSample("ttf_stepend",275,150)}}</div>
+</div>
+
+<div id="ttf_step4end" style="width: 251px; display: inline-block; margin-right: 1px; margin-bottom: 1px;">
+<p><code>transition-timing-function: steps(4, end)</code></p>
+
+<div style="display: none;">
+<pre class="brush:html"> &lt;div class="parent"&gt;
+ &lt;div class="box"&gt;Lorem&lt;/div&gt;
+&lt;/div&gt;
+ </pre>
+
+<pre class="brush:css;">.parent { width: 250px; height:125px;}
+.box {
+ width: 100px;
+ height: 100px;
+ background-color: red;
+ font-size: 20px;
+ left: 0px;
+ top: 0px;
+ position:absolute;
+ -webkit-transition-property: width height background-color font-size left top color;
+ -webkit-transition-duration:2s;
+ -webkit-transition-timing-function: steps(4, end);
+ transition-property: width height background-color font-size left top color;
+ transition-duration:2s;
+ transition-timing-function: steps(4, end);
+}
+.box1{
+ width: 50px;
+ height: 50px;
+ background-color: blue;
+ color: yellow;
+ font-size: 18px;
+ left: 150px;
+ top:25px;
+ position:absolute;
+ -webkit-transition-property: width height background-color font-size left top color;
+ -webkit-transition-duration:2s;
+ -webkit-transition-timing-function: steps(4, end);
+ transition-property: width height background-color font-size left top color;
+ transition-duration:2s;
+ transition-timing-function: steps(4, end);
+}
+</pre>
+
+<pre class="brush:js">function updateTransition() {
+ var el = document.querySelector("div.box");
+
+ if (el) {
+ el.className = "box1";
+ } else {
+ el = document.querySelector("div.box1");
+ el.className = "box";
+ }
+
+ return el;
+}
+
+var intervalID = window.setInterval(updateTransition, 7000);
+</pre>
+</div>
+
+<div>{{EmbedLiveSample("ttf_step4end",275,150)}}</div>
+</div>
+
+<h2 id="规范">规范</h2>
+
+<table class="standard-table">
+ <thead>
+ <tr>
+ <th scope="col">Specification</th>
+ <th scope="col">Status</th>
+ <th scope="col">Comment</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td>{{ SpecName('CSS3 Transitions', '#transition-timing-function', 'transition-timing-function') }}</td>
+ <td>{{ Spec2('CSS3 Transitions') }}</td>
+ <td> </td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="浏览器兼容性">浏览器兼容性</h2>
+
+<p>{{ CompatibilityTable() }}</p>
+
+<div id="compat-desktop">
+<table class="compat-table">
+ <tbody>
+ <tr>
+ <th>Feature</th>
+ <th>Chrome</th>
+ <th>Firefox (Gecko)</th>
+ <th>Internet Explorer</th>
+ <th>Opera</th>
+ <th>Safari</th>
+ </tr>
+ <tr>
+ <td>Basic support</td>
+ <td>{{ CompatVersionUnknown() }}{{ property_prefix("-webkit") }}</td>
+ <td>{{ CompatGeckoDesktop("2.0") }}{{ property_prefix("-moz") }}<br>
+ {{ CompatGeckoDesktop("16.0") }}</td>
+ <td>10</td>
+ <td>11.6{{ property_prefix("-o") }}<br>
+ 12.10 <a href="http://my.opera.com/ODIN/blog/2012/08/03/a-hot-opera-12-50-summer-time-snapshot" title="http://my.opera.com/ODIN/blog/2012/08/03/a-hot-opera-12-50-summer-time-snapshot">#</a></td>
+ <td>{{ CompatVersionUnknown() }}{{ property_prefix("-webkit") }}</td>
+ </tr>
+ </tbody>
+</table>
+</div>
+
+<div id="compat-mobile">
+<table class="compat-table">
+ <tbody>
+ <tr>
+ <th>Feature</th>
+ <th>Android</th>
+ <th>Chrome for Android</th>
+ <th>Firefox Mobile (Gecko)</th>
+ <th>IE Mobile</th>
+ <th>Opera Mobile</th>
+ <th>Safari Mobile</th>
+ </tr>
+ <tr>
+ <td>Basic support</td>
+ <td>{{ CompatVersionUnknown() }}{{ property_prefix("-webkit") }}</td>
+ <td>{{ CompatVersionUnknown() }}{{ property_prefix("-webkit") }}</td>
+ <td>{{ CompatGeckoMobile("2.0") }}{{ property_prefix("-moz") }}<br>
+ {{ CompatGeckoMobile("16.0") }}</td>
+ <td>{{ CompatUnknown() }}</td>
+ <td>{{ CompatUnknown() }}</td>
+ <td>{{ CompatVersionUnknown() }}{{ property_prefix("-webkit") }}</td>
+ </tr>
+ </tbody>
+</table>
+</div>
+
+<h2 id="参考">参考</h2>
+
+<ul>
+ <li><a href="/en-US/docs/CSS/Using_CSS_transitions" title="en/CSS/CSS transitions">Using CSS transitions</a></li>
+ <li>{{ domxref("TransitionEvent") }}</li>
+</ul>