transition
==========

**`transition`** CSS 屬性是 `transition-property` (en-US), `transition-duration`, `transition-timing-function`, and `transition-delay` (en-US)的 特性簡寫。

嘗試一下
----

Transitions 讓你可以定義元件在兩個狀態之間切換的轉場效果。兩個不同狀態可以使用虛擬類別 定義，像是`:hover` (en-US) 或 `:active` (en-US) 亦或是 使用 JavaScript 設定的狀態變化。

語法
--


```css
/\* Apply to 1 property \*/
/\* property name | duration \*/
transition: margin-right 4s;

/\* property name | duration | delay \*/
transition: margin-right 4s 1s;

/\* property name | duration | timing function \*/
transition: margin-right 4s ease-in-out;

/\* property name | duration | timing function | delay \*/
transition: margin-right 4s ease-in-out 1s;

/\* Apply to 2 properties \*/
transition:
  margin-right 4s,
  color 1s;

/\* Apply to all changed properties \*/
transition: all 0.5s ease-out;

/\* Global values \*/
transition: inherit;
transition: initial;
transition: unset;
```


`transition` 屬性可以包含一個或多個轉場設定，每一項設定都以逗點分開。

每一項設定都描述著每一項屬性所對應的轉場效果(或是`all` 及 `none`這兩個特殊值) 。其包含了：

* 無或一個對應的屬性名稱。可以是：
    + 關鍵字 `none`
    + 關鍵字 `all`
    + 以`<custom-ident>` (en-US)命名的 CSS 屬性。
* 無或一個`<single-transition-timing-function>` (en-US) 表示所使用的漸變函式。
* 無、一個或兩個`<time>` (en-US) 值。第一個值會被指派給`transition-duration`, 而第二個則被指派給`transition-delay` (en-US)。

當每個轉場設定不等長時，請參見 當 property values list 之間不等長時... 。簡而言之，多餘的描述(超過實際被執行的數量)會直接被忽略。

### 標準語法
```

transition =   
  <single-transition># (en-US)    
  
<single-transition> =   
  [ (en-US) none | (en-US) <single-transition-property> ] (en-US)  || (en-US)  
  <time> (en-US)                                   || (en-US)  
  <easing-function>                        || (en-US)  
  <time> (en-US)                                     
  
<single-transition-property> =   
  all             | (en-US)  
  <custom-ident> (en-US)    
  
<easing-function> =   
  linear                          | (en-US)  
  <linear-easing-function>        | (en-US)  
  <cubic-bezier-easing-function>  | (en-US)  
  <step-easing-function>            
  
<linear-easing-function> =   
  linear( <linear-stop-list> )    
  
<cubic-bezier-easing-function> =   
  ease                                                | (en-US)  
  ease-in                                             | (en-US)  
  ease-out                                            | (en-US)  
  ease-in-out                                         | (en-US)  
  cubic-bezier( <number [0,1]> (en-US) , <number> (en-US) , <number [0,1]> (en-US) , <number> (en-US) )    
  
<step-easing-function> =   
  step-start                             | (en-US)  
  step-end                               | (en-US)  
  steps( <integer> (en-US) , <step-position>? (en-US) )    
  
<linear-stop-list> =   
  [ (en-US) <linear-stop> ] (en-US)# (en-US)    
  
<step-position> =   
  jump-start  | (en-US)  
  jump-end    | (en-US)  
  jump-none   | (en-US)  
  jump-both   | (en-US)  
  start       | (en-US)  
  end           
  
<linear-stop> =   
  <number> (en-US)               && (en-US)  
  <linear-stop-length>? (en-US)    
  
<linear-stop-length> =   
  <percentage> (en-US){1,2} (en-US)    
  
```

範例
--

CSS 轉場 有更多範例。

規範
--

| Specification |
| --- |
| CSS Transitions # transition-shorthand-property |

|  |  |
| --- | --- |
| 預設值 (en-US) | as each of the properties of the shorthand:* `transition-delay` (en-US): `0s`
* `transition-duration`: `0s`
* `transition-property` (en-US): all
* `transition-timing-function`: `ease`
* `transition-behavior` (en-US): `normal`
 |
| Applies to | all elements, `::before` (en-US) and `::after` (en-US) pseudo-elements |
| 繼承與否 | no |
| Computed value (en-US) | as each of the properties of the shorthand:* `transition-delay` (en-US): as specified
* `transition-duration`: as specified
* `transition-property` (en-US): as specified
* `transition-timing-function`: as specified
* `transition-behavior` (en-US): as specified
 |
| Animation type | Not animatable |

瀏覽器支援情況
-------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.

更多資訊
----

* CSS 轉場
* `TransitionEvent` (en-US)