aboutsummaryrefslogtreecommitdiff
path: root/files/zh-tw/web/css/transition-duration/index.html
diff options
context:
space:
mode:
Diffstat (limited to 'files/zh-tw/web/css/transition-duration/index.html')
-rw-r--r--files/zh-tw/web/css/transition-duration/index.html342
1 files changed, 342 insertions, 0 deletions
diff --git a/files/zh-tw/web/css/transition-duration/index.html b/files/zh-tw/web/css/transition-duration/index.html
new file mode 100644
index 0000000000..f29fa166ca
--- /dev/null
+++ b/files/zh-tw/web/css/transition-duration/index.html
@@ -0,0 +1,342 @@
+---
+title: transition-duration
+slug: Web/CSS/transition-duration
+tags:
+ - CSS
+ - CSS Property
+ - CSS 轉場
+ - Reference
+translation_of: Web/CSS/transition-duration
+---
+<div>{{CSSRef}}</div>
+
+<p><strong><code>transition-duration</code></strong> <a href="/en/CSS" title="CSS">CSS</a> 屬性指定轉場動畫所需經歷的時間,以秒或是毫秒為單位。默認值為0,表示沒有任何轉場動畫。</p>
+
+<div>{{EmbedInteractiveExample("pages/css/transition-duration.html")}}</div>
+
+
+
+<p>你可以指定多個時間長度,每一個時間長度都會被應用在{{ cssxref("transition-property") }} 設定的對應屬性上(which acts as a master list.) 如果指定的時間長度的數量比對應屬性的數量少,那麼時間長度就會被重複使用。反之,多餘的時間長度就會被刪去。而這兩種情況之下的CSS宣告都是有效的。</p>
+
+<h2 id="語法">語法</h2>
+
+<pre class="brush:css no-line-numbers">/* &lt;time&gt; 值 */
+transition-duration: 6s;
+transition-duration: 120ms;
+transition-duration: 1s, 15s;
+transition-duration: 10s, 30s, 230ms;
+
+/* 全域值 */
+transition-duration: inherit;
+transition-duration: initial;
+transition-duration: unset;
+</pre>
+
+<h3 id="值">值</h3>
+
+<dl>
+ <dt><code>&lt;time&gt;</code></dt>
+ <dd>{{cssxref("&lt;time&gt;")}}類型表示轉場動畫從舊狀態轉至新狀態所需要的時間。如果時間長度為0,表示沒有任何轉場,狀態之間會立即改變。若時間長度為負值則無效。</dd>
+</dl>
+
+<h3 id="正式語法">正式語法</h3>
+
+<pre class="syntaxbox">{{csssyntax}}</pre>
+
+<h2 id="範例">範例</h2>
+
+<div>
+<div id="duration_0_5s" style="width: 251px; display: inline-block; margin-right: 1px; margin-bottom: 1px;">
+<p><code>transition-duration: 0.5s</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 transform -webkit-transform color;
+ -webkit-transition-duration:0.5s;
+ -webkit-transition-timing-function: ease-in-out;
+ transition-property: width height background-color font-size left top transform -webkit-transform color;
+ transition-duration:0.5s;
+ transition-timing-function: ease-in-out;
+}
+.box1{
+ transform: rotate(270deg);
+ -webkit-transform: rotate(270deg);
+ 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 transform -webkit-transform color;
+ -webkit-transition-duration:0.5s;
+ -webkit-transition-timing-function: ease-in-out;
+ transition-property: width height background-color font-size left top transform -webkit-transformv color;
+ transition-duration:0.5s;
+ 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("duration_0_5s",275,150)}}</div>
+</div>
+
+<div id="duration_1s" style="width: 251px; display: inline-block; margin-right: 1px; margin-bottom: 1px;">
+<p><code>transition-duration: 1s</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 -webkit-transform color;
+ -webkit-transition-duration:1s;
+ -webkit-transition-timing-function: ease-in-out;
+ transition-property: width height background-color font-size left top transform color;
+ transition-duration:1s;
+ transition-timing-function: ease-in-out;
+}
+.box1{
+ transform: rotate(270deg);
+ -webkit-transform: rotate(270deg);
+ 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 -webkit-transform transform color;
+ -webkit-transition-duration:1s;
+ -webkit-transition-timing-function: ease-in-out;
+ transition-property: width height background-color font-size left top transform -webkit-transform color;
+ transition-duration:1s;
+ 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("duration_1s",275,150)}}</div>
+</div>
+
+<div id="duration_2s" style="width: 251px; display: inline-block; margin-right: 1px; margin-bottom: 1px;">
+<p><code>transition-duration: 2s</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 transform -webkit-transform color;
+ -webkit-transition-duration:2s;
+ -webkit-transition-timing-function: ease-in-out;
+ transition-property: width height background-color font-size left top transform -webkit-transform color;
+ transition-duration:2s;
+ transition-timing-function: ease-in-out;
+}
+.box1{
+ transform: rotate(270deg);
+ -webkit-transform: rotate(270deg);
+ 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 transform -webkit-transform color;
+ -webkit-transition-duration:2s;
+ -webkit-transition-timing-function: ease-in-out;
+ transition-property: width height background-color font-size left top transform -webkit-transform 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("duration_2s",275,150)}}</div>
+</div>
+
+<div id="duration_4s" style="width: 251px; display: inline-block; margin-right: 1px; margin-bottom: 1px;">
+<p><code>transition-duration: 4s</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 transform -webkit-transform color;
+ -webkit-transition-duration:4s;
+ -webkit-transition-timing-function: ease-in-out;
+ transition-property: width height background-color font-size left top transform -webkit-transform color;
+ transition-duration:4s;
+ transition-timing-function: ease-in-out;
+}
+.box1{
+ transform: rotate(270deg);
+ -webkit-transform: rotate(270deg);
+ 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 transform -webkit-transform color;
+ -webkit-transition-duration:4s;
+ -webkit-transition-timing-function: ease-in-out;
+ transition-property: width height background-color font-size left top transform -webkit-transform color;
+ transition-duration:4s;
+ 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("duration_4s",275,150)}}</div>
+</div>
+</div>
+
+<h2 id="規範">規範</h2>
+
+<table class="standard-table">
+ <thead>
+ <tr>
+ <th scope="col">規範</th>
+ <th scope="col">狀態</th>
+ <th scope="col">備註</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td>{{ SpecName('CSS3 Transitions', '#transition-duration', 'transition-duration') }}</td>
+ <td>{{ Spec2('CSS3 Transitions') }}</td>
+ <td>Initial definition</td>
+ </tr>
+ </tbody>
+</table>
+
+<p>{{cssinfo}}</p>
+
+<h2 id="瀏覽器支援情形">瀏覽器支援情形</h2>
+
+
+
+<p>{{Compat("css.properties.transition-duration")}}</p>
+
+<h2 id="更多資訊">更多資訊</h2>
+
+<ul>
+ <li><a href="/zh-TW/docs/Web/CSS/CSS_Transitions/Using_CSS_transitions" title="en/CSS/CSS transitions">CSS 轉場 </a></li>
+ <li>{{ domxref("TransitionEvent") }}</li>
+</ul>