?
This document uses PHP Chinese website manual Release
transition:<single-transition>[,<single-transition>]*
<single-transition> = [ none | <single-transition-property> ] || <time> || <single-transition-timing-function> || <time>
默認(rèn)值:看每個(gè)獨(dú)立屬性
適用于:所有元素,包含偽對(duì)象:after和:before
繼承性:無(wú)
動(dòng)畫性:否
計(jì)算值:看每個(gè)獨(dú)立屬性
媒體:交互
<' transition-property '>:檢索或設(shè)置對(duì)象中的參與過(guò)渡的屬性
<' transition-duration '>:檢索或設(shè)置對(duì)象過(guò)渡的持續(xù)時(shí)間
<' transition-timing-function '>:檢索或設(shè)置對(duì)象中過(guò)渡的動(dòng)畫類型
<' transition-delay '>:檢索或設(shè)置對(duì)象延遲過(guò)渡的時(shí)間
注意:如果只提供一個(gè)<time>參數(shù),則為 <' transition-duration '> 的值定義;如果提供二個(gè)<time>參數(shù),則第一個(gè)為 <' transition-duration '> 的值定義,第二個(gè)為 <' transition-delay '> 的值定義
可以為同一元素的多個(gè)屬性定義過(guò)渡效果。示例:
縮寫方式:
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;
如果定義了多個(gè)過(guò)渡的屬性,而其他屬性只有一個(gè)參數(shù)值,則表明所有需要過(guò)渡的屬性都應(yīng)用同一個(gè)參數(shù)值。據(jù)此可以對(duì)上面的例子進(jìn)行縮寫:
拆分方式:
transition-property: border-color, background-color, color;
transition-duration: .5s;
transition-timing-function: ease-in;
transition-delay: .1s;
如果需要定義多個(gè)過(guò)渡屬性且不想指定具體是哪些屬性過(guò)渡,同時(shí)其他屬性只有一個(gè)參數(shù)值,據(jù)此可以對(duì)上面的例子進(jìn)行縮寫:
縮寫方式:
transition: all .5s ease-in .1s;
拆分方式:
transition-property:all; transition-duration: .5s; transition-timing-function: ease-in; transition-delay: .1s;
對(duì)應(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參考手冊(cè)_web前端開(kāi)發(fā)參考手冊(cè)系列</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>請(qǐng)將鼠標(biāo)移動(dòng)到下面的矩形上:</h1> <ul class="test"> <li>背景色過(guò)渡</li> <li>背景色過(guò)渡</li> <li>背景色過(guò)渡</li> <li>背景色過(guò)渡</li> <li>背景色過(guò)渡</li> </ul> </body> </html>
點(diǎn)擊 "運(yùn)行實(shí)例" 按鈕查看在線實(shí)例