CSS3 animation-timing-function
animation-timing-function屬性用於設定animation動畫的過渡型別。
更多關於animation動畫可以參閱CSS3 animation一章節。
語法結構:
[CSS] 純文字檢視 複製程式碼animation-timing-function:linear | ease | ease-in | ease-out | ease-in-out | cubic-bezier(<number>, <number>, <number>, <number>) [ , linear | ease | ease-in | ease-out | ease-in-out | cubic-bezier(<number>, <number>, <number>, <number>) ]*
引數解析:
(1).linear:線性過渡。等同於貝塞爾曲線(0.0, 0.0, 1.0, 1.0)
(2).ease:平滑過渡。等同於貝塞爾曲線(0.25, 0.1, 0.25, 1.0)
(3).ease-in:由慢到快。等同於貝塞爾曲線(0.42, 0, 1.0, 1.0)
(4).ease-out:由快到慢。等同於貝塞爾曲線(0, 0, 0.58, 1.0)
(5).ease-in-out:由慢到快再到慢。等同於貝塞爾曲線(0.42, 0, 0.58, 1.0)
(6).cubic-bezier(<number>, <number>, <number>, <number>): 特定的貝塞爾曲線型別,4個數值需在[0, 1]區間內;賽貝爾曲線型別可以線上生成,如貝塞爾曲線生成工具。
特別說明:如果提供多個屬性值,以逗號進行分隔。
程式碼例項:
[HTML] 純文字檢視 複製程式碼執行程式碼<!DOCTYPE html> <html> <head> <meta charset=" utf-8"> <meta name="author" content="http://www.softwhy.com/" /> <title>螞蟻部落</title> <style type="text/css"> div{ width:100px; height:100px; background:red; position:relative; animation:theanimation 5s infinite alternate; -webkit-animation:theanimation 5s infinite alternate; -moz-animation:theanimation 5s infinite alternate; -o-animation:theanimation 5s infinite alternate; animation-timing-function:ease-in; -webkit-animation-timing-function:ease-in; -moz-animation-timing-function:ease-in; -o-animation-timing-function:ease-in; } @keyframes theanimation{ 0% {left:0px;} 100% {left:200px;} } @-webkit-keyframes theanimation{ 0% {left:0px;} 100% {left:200px;} } @-moz-keyframes theanimation{ 0% {left:0px;} 100% {left:200px;} } @-o-keyframes theanimation{ 0% {left:0px;} 100% {left:200px;} } </style> </head> <body> <div></div> </body> </html>
以上程式碼可以使用animation-timing-function屬性設定動畫由慢到快進行過渡。
[HTML] 純文字檢視 複製程式碼執行程式碼<!DOCTYPE html> <html> <head> <meta charset=" utf-8"> <meta name="author" content="http://www.softwhy.com/" /> <title>螞蟻部落</title> <style type="text/css"> div{ width:100px; height:100px; background:red; position:relative; animation:ant-1 5s infinite alternate,ant-2 2s infinite alternate; -webkit-animation:ant-1 5s infinite alternate,ant-2 2s infinite alternate; -moz-animation:ant-1 5s infinite alternate,ant-2 2s infinite alternate; -o-animation:ant-1 5s infinite alternate,ant-2 2s infinite alternate; animation-timing-function:ease-in,ease-out; -webkit-animation-timing-function:ease-in,ease-out; -moz-animation-timing-function:ease-in,ease-out; -o-animation-timing-function:ease-in,ease-out; } @keyframes ant-1{ 0% {left:0px;} 100% {left:200px;} } @-webkit-keyframes ant-1{ 0% {left:0px;} 100% {left:200px;} } @-moz-keyframes ant-1{ 0% {left:0px;} 100% {left:200px;} } @-o-keyframes ant-1{ 0% {left:0px;} 100% {left:200px;} } @keyframes ant-2{ 0% {top:0px;} 100% {top:200px;} } @-webkit-keyframes ant-2{ 0% {top:0px;} 100% {top:200px;} } @-moz-keyframes ant-2{ 0% {top:0px;} 100% {top:200px;} } @-o-keyframes ant-2{ 0% {top:0px;} 100% {top:200px;} } </style> </head> <body> <div></div> </body> </html>
以上程式碼可以通過animation-timing-function屬性設定兩個動畫的過渡型別。
相關文章
- CSS3CSSS3
- CSS3簡明教程之初識CSS3CSSS3
- CSS3 quotesCSSS3
- css3省略……CSSS3
- CSS3 remCSSS3REM
- CSS3 vhCSSS3
- CSS3 vwCSSS3
- CSS3 vmaxCSSS3
- CSS3 vminCSSS3
- CSS3 TransitionCSSS3
- CSS3 @supportsCSSS3
- CSS3 currentColorCSSS3
- CSS3 clipCSSS3
- CSS3 ::SelectionCSSS3
- CSS3 counter()CSSS3
- CSS3 attr()CSSS3
- CSS3 orderCSSS3
- CSS3 @keyframesCSSS3
- CSS3 rotate()CSSS3
- CSS3 columnsCSSS3
- css3 漸變CSSS3
- CSS3之背景CSSS3
- CSS3 perspective(n)CSSS3
- CSS3象棋效果CSSS3
- CSS3 之 flexCSSS3Flex
- css3 新特性CSSS3
- CSS3 七 字型CSSS3
- CSS3筆記CSSS3筆記
- CSS3新特性CSSS3
- css3漸變CSSS3
- CSS3初識CSSS3
- CSS3簡明教程之徵服CSS3選擇器CSSS3
- CSS3選擇器02—CSS3部分選擇器CSSS3
- css3核心屬性CSSS3
- CSS3 動畫解析CSSS3動畫
- CSS3 animation 練習CSSS3
- CSS3 transform-styleCSSS3ORM
- CSS3 矩形切角效果CSSS3