Warning: error_log(/data/www/wwwroot/hmttv.cn/caches/error_log.php): failed to open stream: Permission denied in /data/www/wwwroot/hmttv.cn/phpcms/libs/functions/global.func.php on line 537 Warning: error_log(/data/www/wwwroot/hmttv.cn/caches/error_log.php): failed to open stream: Permission denied in /data/www/wwwroot/hmttv.cn/phpcms/libs/functions/global.func.php on line 537
CSS中animation屬性大家都很常見,而@keyframes大家有聽說過嗎?animation屬性里引用@keyframes有一種簡寫方式,展開來一共有8個子屬性,通過它們,我們可以控制各種的動畫過程。
子屬性
animation-name: 指定一個 @keyframes 的名稱,動畫將要使用這個@keyframes定義。
animation-duration: 整個動畫需要的時長。
animation-timing-function: 動畫進行中的時速控制,比如 ease或 linear
animation-timing-delay: 動畫延遲時間
animation-direction: 動畫重復執行時運動的方向
animation-iteration-count: 動畫循環執行次數
animation-fill-mode: 設置動畫執行完成后/開始執行前的狀態,比如,你可以讓動畫執行完成后停留在最后一幕,或恢復到初始狀態。
animation-play-state: 暫停/啟動動畫。
接下來給大家展示下:
HTML:
<div class="element"></div>
CSS:
顯示效果:
大家可以嘗試自己做下,非常炫酷哦!了解以上的屬性,再也不用擔心動畫效果了。
切版 qieban(.cn)
例
使用簡寫屬性把 animation 綁定到一個<div> 元素:
div{animation:mymove5sinfinite; -webkit-animation:mymove5sinfinite; /* Safari 和 Chrome */}
瀏覽器支持
表格中的數字表示支持該屬性的第一個瀏覽器版本號。
緊跟在 -webkit-, -ms- 或 -moz- 前的數字為支持該前綴屬性的第一個瀏覽器版本號。
屬性 | |||||
---|---|---|---|---|---|
animation | 43.04.0 -webkit- | 10.0 | 16.05.0 -moz- | 9.04.0 -webkit- | 30.015.0 -webkit-12.0 -o- |
默認值: | none 0 ease 0 1 normal |
---|---|
繼承: | no |
版本: | CSS3 |
JavaScript 語法: | object.style.animation="mymove 5s infinite" |
語法
animation: animation: name duration timing-function delay iteration-count direction fill-mode play-state;;
值 | 說明 |
---|---|
animation-name | 指定要綁定到選擇器的關鍵幀的名稱 |
animation-duration | 動畫指定需要多少秒或毫秒完成 |
animation-timing-function | 設置動畫將如何完成一個周期 |
animation-delay | 設置動畫在啟動前的延遲間隔。 |
animation-iteration-count | 定義動畫的播放次數。 |
animation-direction | 指定是否應該輪流反向播放動畫。 |
animation-fill-mode | 規定當動畫不播放時(當動畫完成時,或當動畫有一個延遲未開始播放時),要應用到元素的樣式。 |
animation-play-state | 指定動畫是否正在運行或已暫停。 |
initial | 設置屬性為其默認值。 閱讀關于 initial的介紹。 |
inherit | 從父元素繼承屬性。 閱讀關于 initinherital的介紹。 |
如您還有不明白的可以在下面與我留言或是與我探討QQ群{{308855039:0}},我們一起飛!
*請認真填寫需求信息,我們會在24小時內與您取得聯系。