麻豆小视频在线观看_中文黄色一级片_久久久成人精品_成片免费观看视频大全_午夜精品久久久久久久99热浪潮_成人一区二区三区四区

首頁 > 開發(fā) > CSS > 正文

對CSS3中動畫(animation)的實例詳解

2020-03-24 16:19:48
字體:
供稿:網(wǎng)友
一:動畫(animation)的參數(shù)詳解

由于上面用到了animation動畫,這里詳細介紹下這個animation的參數(shù)。

簡介

CSS動畫(Animations)簡單說就是在一段固定的動畫時間內(nèi)暗中在某一頻率內(nèi)改變其CSS某個或某些值,從而達到視覺上的轉(zhuǎn)換動畫效果。Animations的很多方面都是可以控制的,包括動畫運行時間,開始值和結(jié)束值,還有動畫的暫停和延遲其開始時間等。

語法

single-animation = single-animation-name || time || single-animation-timing-function || time || single-animation-iteration-count || single-animation-direction || single-animation-fill-mode || single-animation-play-state

animation-name :檢索或設置對象所應用的動畫名稱
animation-duration :檢索或設置對象動畫的持續(xù)時間
animation-timing-function :檢索或設置對象動畫的過渡類型
animation-delay :檢索或設置對象動畫延遲的時間
animation-iteration-count :檢索或設置對象動畫的循環(huán)次數(shù)
animation-direction :檢索或設置對象動畫在循環(huán)中是否反向運動
animation-fill-mode :檢索或設置對象動畫時間之外的狀態(tài)
animation-play-state :檢索或設置對象動畫的狀態(tài)。w3c正考慮是否將該屬性移除,因為動畫的狀態(tài)可以通過其它的方式實現(xiàn),比如重設樣式

animation

所有動畫屬性的簡寫屬性,除了 animation-play-state 屬性。

animation-name

規(guī)定 @keyframes 動畫的名稱。就是@keyframes后面跟著的動畫名稱。

animation-duration

規(guī)定動畫完成一個周期所花費的秒或毫秒。默認是 0。

animation-timing-function

規(guī)定動畫的速度曲線。默認是 ease 。

常見的動畫速度參數(shù):

linear:線性過渡。等同于貝塞爾曲線(0.0, 0.0, 1.0, 1.0)

ease:平滑過渡。等同于貝塞爾曲線(0.25, 0.1, 0.25, 1.0)

ease-in:由慢到快。等同于貝塞爾曲線(0.42, 0, 1.0, 1.0)

ease-out:由快到慢。等同于貝塞爾曲線(0, 0, 0.58, 1.0)

ease-in-out:由慢到快再到慢。等同于貝塞爾曲線(0.42, 0, 0.58, 1.0)

step-start:等同于 steps(1, start)

step-end:等同于 steps(1, end)

steps( integer [, [ start | end ] ]?):接受兩個參數(shù)的步進函數(shù)。第一個參數(shù)必須為正整數(shù),指定函數(shù)的步數(shù)。第二個參數(shù)取值可以是start或end,指定每一步的值發(fā)生變化的時間點。第二個參數(shù)是可選的,默認值為end。

cubic-bezier( number , number , number , number ):特定的貝塞爾曲線類型,4個數(shù)值需在[0, 1]區(qū)間內(nèi)

animation-delay

規(guī)定動畫何時開始。默認是 0。也即是指動畫延時執(zhí)行時間。

animation-iteration-count

規(guī)定動畫被播放的次數(shù)。默認是 1。當然,我們可以設置2次,3次,依次遞推。還有個無線循環(huán)關(guān)鍵字infinite,也即是反復循環(huán)播放動畫。

animation-direction

規(guī)定動畫是否在下一周期逆向地播放。默認是 normal 。當然還有下列值:

reverse:反方向運行

alternate:動畫先正常運行再反方向運行,并持續(xù)交替運行

alternate-reverse:動畫先反運行再正方向運行,并持續(xù)交替運行

animation-fill-mode

規(guī)定對象動畫時間之外的狀態(tài)。

none:默認值。不設置對象動畫之外的狀態(tài)

forwards:設置對象狀態(tài)為動畫結(jié)束時的狀態(tài)

backwards:設置對象狀態(tài)為動畫開始時的狀態(tài)

both:設置對象狀態(tài)為動畫結(jié)束或開始的狀態(tài),動畫開始之前是 from 或 0% 關(guān)鍵幀;動畫完成之后是 to 或 100% 關(guān)鍵幀狀態(tài)。

animation-play-state

規(guī)定動畫是否正在運行或暫停。默認是 running 。還有個值paused:暫停。

二:animation動畫實例實例一使用from to:
div{width:100px;height:100px;background:red;position:relative;animation:mymove 5s infinite;-moz-animation:mymove 5s infinite; /*Firefox*/-webkit-animation:mymove 5s infinite; /*Safari and Chrome*/}@keyframes mymove{from {left:0px;}to {left:200px;}}@-moz-keyframes mymove { /*Firefox*/from {left:0px;}to {left:200px;}}@-webkit-keyframes mymove{ /*Safari and Chrome*/from {left:0px;}to {left:200px;}}
實例二使用百分比:
@keyframes myfirst{0% {background: red; left:0px; top:0px;}25% {background: yellow; left:200px; top:0px;}50% {background: blue; left:200px; top:200px;}75% {background: green; left:0px; top:200px;}100% {background: red; left:0px; top:0px;}}@-moz-keyframes myfirst{ /* Firefox */0% {background: red; left:0px; top:0px;}25% {background: yellow; left:200px; top:0px;}50% {background: blue; left:200px; top:200px;}75% {background: green; left:0px; top:200px;}100% {background: red; left:0px; top:0px;}}@-webkit-keyframes myfirst{ /* Safari 和 Chrome */0% {background: red; left:0px; top:0px;}25% {background: yellow; left:200px; top:0px;}50% {background: blue; left:200px; top:200px;}75% {background: green; left:0px; top:200px;}100% {background: red; left:0px; top:0px;}}@-o-keyframes myfirst {/* Opera */0% {background: red; left:0px; top:0px;}25% {background: yellow; left:200px; top:0px;}50% {background: blue; left:200px; top:200px;}75% {background: green; left:0px; top:200px;}100% {background: red; left:0px; top:0px;}}
實例三,利用js+Transform和Animation實現(xiàn)3D動畫

示例地址:

只有webkit內(nèi)核的瀏覽器才能看到相關(guān)3D動畫效果。

實現(xiàn)效果如圖所示:

css代碼:

body {font-family: Lucida Grande , Verdana, Arial;font-size: 12px; } #stage {margin: 150px auto;width: 600px;height: 400px;-webkit-perspective: 800; } #rotate {margin: 0 auto;width: 600px;height: 400px;-webkit-transform-style: preserve-3d;-webkit-animation-name: x-spin;-webkit-animation-duration: 7s;-webkit-animation-iteration-count: infinite;-webkit-animation-timing-function: linear; } .ring {margin: 0 auto;height: 110px;width: 600px;-webkit-transform-style: preserve-3d;-webkit-animation-iteration-count: infinite;-webkit-animation-timing-function: linear; .ring :nth-child(odd) {background-color: #995C7F; } .ring :nth-child(even) {background-color: #835A99; } .poster {position: absolute;left: 250px;width: 100px;height: 100px;opacity: 0.7;color: rgba(0,0,0,0.9);-webkit-border-radius: 10px; .poster p {font-family: Georgia , serif;font-size: 36px;font-weight: bold;text-align: center;margin-top: 28px; } #ring-1 {-webkit-animation-name: y-spin;-webkit-animation-duration: 5s; } #ring-2 {-webkit-animation-name: back-y-spin;-webkit-animation-duration: 4s; } #ring-3 {-webkit-animation-name: y-spin;-webkit-animation-duration: 3s; } @-webkit-keyframes x-spin {0% { -webkit-transform: rotateX(0deg); }50% { -webkit-transform: rotateX(180deg); }100% { -webkit-transform: rotateX(360deg); } } @-webkit-keyframes y-spin {0% { -webkit-transform: rotateY(0deg); }50% { -webkit-transform: rotateY(180deg); }100% { -webkit-transform: rotateY(360deg); } } @-webkit-keyframes back-y-spin {0% { -webkit-transform: rotateY(360deg); }50% { -webkit-transform: rotateY(180deg); }100% { -webkit-transform: rotateY(0deg); } }

html代碼:

 div id= stage  div id= rotate div id= ring-1 >

js代碼:

const POSTERS_PER_ROW = 12;const RING_RADIUS = 200;function setup_posters (row){var posterAngle = 360 / POSTERS_PER_ROW;for (var i = 0; i POSTERS_PER_ROW; i ++) { var poster = document.createElement( div  poster.className = poster  var transform = rotateY( + (posterAngle * i) + deg) translateZ( + RING_RADIUS + px)  poster.style.webkitTransform = transform;  var content = poster.appendChild(document.createElement( p  content.textContent = i; row.appendChild(poster);}function init (){ setup_posters(document.getElementById( ring-1  setup_posters(document.getElementById( ring-2  setup_posters(document.getElementById( ring-3 window.addEventListener( load , init, false);

以上就是對CSS3中動畫(animation)的實例詳解的詳細內(nèi)容,html教程

鄭重聲明:本文版權(quán)歸原作者所有,轉(zhuǎn)載文章僅為傳播更多信息之目的,如作者信息標記有誤,請第一時間聯(lián)系我們修改或刪除,多謝。

發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 色婷婷av一区二区三区久久 | 亚洲午夜精品视频 | 成人激情在线观看 | 涩涩屋av | 日韩黄色免费电影 | 国产一区二区久久精品 | xxxx hd videos | 欧美成人高清在线 | 国产免费视频一区二区裸体 | 91成人免费网站 | 日本中文不卡视频 | 精品国产乱码久久久久久久 | 亚洲精品动漫在线观看 | 草莓福利社区在线 | 久草视频手机在线观看 | av观看网站| 成人性生活视频在线观看 | 精品一区在线视频 | 男人久久天堂 | 日本高清无遮挡 | 天天草天天干天天射 | 免费国产人成网站 | 色屁屁xxxxⅹ在线视频 | 九九热精品视频在线播放 | 欧美日韩免费看 | www.99热精品| 国产手机av在线 | 福利免费在线观看 | 久久久久久久久久久久久久久伊免 | 精久久久| 国产精品久久久久久久久久10秀 | 国产激情精品一区二区三区 | 少妇一级淫片免费放正片 | 成人一级黄色片 | 午夜色视频在线观看 | 九九热精品免费视频 | 欧洲狠狠鲁 | 免费在线成人网 | 亚洲 综合 欧美 动漫 丝袜图 | v11av在线播放 | 色视频一区二区 |