aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/css/transition-delay
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-delay
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-delay')
-rw-r--r--files/zh-cn/web/css/transition-delay/index.html398
1 files changed, 398 insertions, 0 deletions
diff --git a/files/zh-cn/web/css/transition-delay/index.html b/files/zh-cn/web/css/transition-delay/index.html
new file mode 100644
index 0000000000..19ba83c5b8
--- /dev/null
+++ b/files/zh-cn/web/css/transition-delay/index.html
@@ -0,0 +1,398 @@
+---
+title: transition-delay
+slug: Web/CSS/transition-delay
+tags:
+ - CSS 属性
+ - CSS 过渡
+ - transition-delay
+ - 动画过渡
+translation_of: Web/CSS/transition-delay
+---
+<div>{{CSSRef}}{{SeeCompatTable}}</div>
+
+<h2 id="概要">概要</h2>
+
+<p>CSS的<strong>transition-delay</strong>属性规定了在<a href="/en-US/docs/Web/CSS/CSS_Transitions/Using_CSS_transitions">过渡效果</a>开始作用之前需要等待的时间。</p>
+
+<p>值以秒(s)或毫秒(ms)为单位,表明动画过渡效果将在何时开始。取值为正时会延迟一段时间来响应过渡效果;取值为负时会导致过渡立即开始。</p>
+
+<p>你可以指定多个延迟时间,每个延迟将会分别作用于你所指定的相符合的css属性(<strong>transition-property</strong>)</p>
+
+<p>{{cssinfo}}</p>
+
+<h2 id="语法">语法</h2>
+
+<pre class="brush: css">/* &lt;time&gt;?值 */
+transition-delay: 3s;
+transition-delay: 2s, 4ms;
+
+/* 全局变量 */
+transition-delay: inherit;
+transition-delay: initial;
+transition-delay: unset;
+</pre>
+
+<h3 id="取值">取值</h3>
+
+<dl>
+ <dt><code>&lt;time&gt;</code></dt>
+ <dd>表明动画效果属性生效之前需要等待的时间。</dd>
+</dl>
+
+<h3 id="语法形式">语法形式</h3>
+
+<pre class="syntaxbox">{{csssyntax}}</pre>
+
+<h2 id="举例">举例</h2>
+
+<div>
+<div id="delay_0_5s" style="width: 251px; display: inline-block; margin-right: 1px; margin-bottom: 1px;">
+<p><code>transition-delay: 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 color;
+ -webkit-transition-duration:2s;
+ -webkit-transition-delay:0.5s;
+ -webkit-transition-timing-function: linear;
+ transition-property: width height background-color font-size left top color;
+ transition-duration:2s;
+ transition-delay:0.5s;
+ 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-delay:0.5s;
+ -webkit-transition-timing-function: linear;
+ transition-property: width height background-color font-size left top color;
+ transition-duration:2s;
+ transition-delay:0.5s;
+ 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("delay_0_5s",275,150)}}</div>
+</div>
+
+<div id="delay_1s" style="width: 251px; display: inline-block; margin-right: 1px; margin-bottom: 1px;">
+<p><code>transition-delay: 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 color;
+ -webkit-transition-duration:2s;
+ -webkit-transition-delay:1s;
+ -webkit-transition-timing-function: linear;
+ transition-property: width height background-color font-size left top color;
+ transition-duration:2s;
+ transition-delay:1s;
+ 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-delay:1s;
+ -webkit-transition-timing-function: linear;
+ transition-property: width height background-color font-size left top color;
+ transition-duration:2s;
+ transition-delay:1s;
+ 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("delay_1s",275,150)}}</div>
+</div>
+
+<div id="delay_2s" style="width: 251px; display: inline-block; margin-right: 1px; margin-bottom: 1px;">
+<p><code>transition-delay: 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 color;
+ -webkit-transition-duration:2s;
+ -webkit-transition-delay:2s;
+ -webkit-transition-timing-function: linear;
+ transition-property: width height background-color font-size left top color;
+ transition-duration:2s;
+ transition-delay: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-delay:2s;
+ -webkit-transition-timing-function: linear;
+ transition-property: width height background-color font-size left top color;
+ transition-duration:2s;
+ transition-delay: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("delay_2s",275,150)}}</div>
+</div>
+
+<div id="delay_4s" style="width: 251px; display: inline-block; margin-right: 1px; margin-bottom: 1px;">
+<p><code>transition-delay: 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 color;
+ -webkit-transition-duration:2s;
+ -webkit-transition-delay:4s;
+ -webkit-transition-timing-function: ease-in-out;
+ transition-property: width height background-color font-size left top color;
+ transition-duration:2s;
+ transition-delay:4s;
+ 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-delay:4s;
+ -webkit-transition-timing-function: ease-in-out;
+ transition-property: width height background-color font-size left top color;
+ transition-duration:2s;
+ transition-delay: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("delay_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-delay', 'transition-delay')}}</td>
+ <td>{{Spec2('CSS3 Transitions')}}</td>
+ <td>Initial definition</td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="浏览器兼容性">浏览器兼容性</h2>
+
+<p>{{CompatibilityTable}}</p>
+
+<div id="compat-desktop">
+<table class="compat-table">
+ <tbody>
+ <tr>
+ <th>?特性</th>
+ <th>Chrome</th>
+ <th>Firefox (Gecko)</th>
+ <th>Internet Explorer</th>
+ <th>Opera</th>
+ <th>Safari</th>
+ </tr>
+ <tr>
+ <td>基本支持</td>
+ <td>1.0 {{property_prefix("-webkit")}}</td>
+ <td>{{CompatGeckoDesktop("2.0")}} {{property_prefix("-moz")}}<br>
+ {{CompatGeckoDesktop("16.0")}}</td>
+ <td>10.0</td>
+ <td>11.6 {{property_prefix("-o")}}<br>
+ 12.10</td>
+ <td>3.0 {{property_prefix("-webkit")}}</td>
+ </tr>
+ </tbody>
+</table>
+</div>
+
+<div id="compat-mobile">
+<table class="compat-table">
+ <tbody>
+ <tr>
+ <th>特性</th>
+ <th>Android</th>
+ <th>Firefox Mobile (Gecko)</th>
+ <th>IE Mobile</th>
+ <th>Opera Mobile</th>
+ <th>Safari Mobile</th>
+ </tr>
+ <tr>
+ <td>基本支持</td>
+ <td>2.1 {{property_prefix("-webkit")}}</td>
+ <td>{{CompatGeckoMobile("2.0")}} {{property_prefix("-moz")}}<br>
+ {{CompatGeckoMobile("16.0")}}</td>
+ <td>{{CompatUnknown}}</td>
+ <td>10.0 {{property_prefix("-o")}}<br>
+ 12.10<sup>[1]</sup></td>
+ <td>3.2 {{property_prefix("-webkit")}}</td>
+ </tr>
+ </tbody>
+</table>
+</div>
+
+<p>[1] 详见 <a href="http://my.opera.com/ODIN/blog/2012/08/03/a-hot-opera-12-50-summer-time-snapshot">blog post about Opera 12.50</a>.</p>
+
+<h2 id="扩展阅读">扩展阅读</h2>
+
+<ul>
+ <li><a href="/en-US/docs/Web/CSS/CSS_Transitions/Using_CSS_transitions">Using CSS transitions</a></li>
+ <li>{{domxref("TransitionEvent")}}</li>
+</ul>