?
本文檔使用 php中文網(wǎng)手冊 發(fā)布
transition:<single-transition>[,<single-transition>]*
<single-transition> = [ none | <single-transition-property> ] || <time> || <single-transition-timing-function> || <time>
默認值:看每個獨立屬性
適用于:所有元素,包含偽對象:after和:before
繼承性:無
動畫性:否
計算值:看每個獨立屬性
媒體:交互
<' transition-property '>:檢索或設(shè)置對象中的參與過渡的屬性
<' transition-duration '>:檢索或設(shè)置對象過渡的持續(xù)時間
<' transition-timing-function '>:檢索或設(shè)置對象中過渡的動畫類型
<' transition-delay '>:檢索或設(shè)置對象延遲過渡的時間
注意:如果只提供一個<time>參數(shù),則為 <' transition-duration '> 的值定義;如果提供二個<time>參數(shù),則第一個為 <' transition-duration '> 的值定義,第二個為 <' transition-delay '> 的值定義
可以為同一元素的多個屬性定義過渡效果。示例:
縮寫方式:
transition: border-color .5s ease-in .1s, background-color .5s ease-in .1s, color .5s ease-in .1s;
拆分方式:
transition-property: border-color, background-color, color; transition-duration: .5s, .5s, .5s; transition-timing-function: ease-in, ease-in, ease-in; transition-delay: .1s, .1s, .1s;
如果定義了多個過渡的屬性,而其他屬性只有一個參數(shù)值,則表明所有需要過渡的屬性都應(yīng)用同一個參數(shù)值。據(jù)此可以對上面的例子進行縮寫:
拆分方式:
transition-property: border-color, background-color, color;
transition-duration: .5s;
transition-timing-function: ease-in;
transition-delay: .1s;
如果需要定義多個過渡屬性且不想指定具體是哪些屬性過渡,同時其他屬性只有一個參數(shù)值,據(jù)此可以對上面的例子進行縮寫:
縮寫方式:
transition: all .5s ease-in .1s;
拆分方式:
transition-property:all; transition-duration: .5s; transition-timing-function: ease-in; transition-delay: .1s;
對應(yīng)的腳本特性為transition。
Values | IE | Firefox | Chrome | Safari | Opera | iOS Safari | Android Browser | Android Chrome |
---|---|---|---|---|---|---|---|---|
Basic Support | 6.0-9.0 | 2.0-3.6 | 4.0-25.0-webkit- | 6.0-webkit- | 15.0+ | 6.0-6.1-webkit- | 2.1-4.3-webkit- | 18.0-24.0-webkit- |
10.0+ | 4.0-15.0-moz- | 26.0+ | 6.1+ | 7.0+ | 4.4.4+ | 25.0+ | ||
16.0+ |
<!DOCTYPE html> <html lang="zh-cmn-Hans"> <head> <meta charset="utf-8" /> <title>transition_CSS參考手冊_web前端開發(fā)參考手冊系列</title> <meta name="author" content="Joy Du(飄零霧雨), dooyoe@gmail.com, www.doyoe.com" /> <style> h1{font-size:16px;} .test{overflow:hidden;width:100%;margin:0;padding:0;list-style:none;} .test li{float:left;width:100px;height:100px;margin:0 5px;border:1px solid #ddd;background-color:#eee;text-align:center; -webkit-transition:background-color .5s ease-in; -moz-transition:background-color .5s ease-in; transition:background-color .5s ease-in; } .test li:nth-child(1):hover{background-color:#bbb;} .test li:nth-child(2):hover{background-color:#999;} .test li:nth-child(3):hover{background-color:#630;} .test li:nth-child(4):hover{background-color:#090;} .test li:nth-child(5):hover{background-color:#f00;} </style> </head> <body> <h1>請將鼠標移動到下面的矩形上:</h1> <ul class="test"> <li>背景色過渡</li> <li>背景色過渡</li> <li>背景色過渡</li> <li>背景色過渡</li> <li>背景色過渡</li> </ul> </body> </html>
點擊 "運行實例" 按鈕查看在線實例