css3 - css做動(dòng)畫(huà)效果
問(wèn)題描述
把紅色框內(nèi)做成那種來(lái)回動(dòng)畫(huà)效果怎么做啊?
問(wèn)題解答
回答1:<!DOCTYPE html><html><head><style> p{ width:100px; height:100px; background:red; position:relative; animation:mymove 1s infinite; -moz-animation:mymove 1s infinite; /* Firefox */ -webkit-animation:mymove 1s infinite; /* Safari and Chrome */ -o-animation:mymove 1s infinite; /* Opera */ animation-direction: alternate;}@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;}}@-o-keyframes mymove /* Opera */{ from {left:0px;} to {left:200px;}}</style></head><body><p></p></body></html>
運(yùn)行一下上面的代碼,改于w3school。
鏈接為:http://www.w3school.com.cn/cs...
回答2:給你個(gè)鏈接 自己對(duì)著改參數(shù)
回答3:給那個(gè)三角圖片 擺好位置后, 用類(lèi)去控制動(dòng)作。
比如
.move { -webkit-animation-name:’example’; // other code} @-webkit-keyframes ’example’ { 0% {-webkit-transform: translateX(0); } 50% { -webkit-transform: translateX(100px); } 100% { -webkit-transform: translateX(0); } } // 補(bǔ)充說(shuō)明: -webkit-animation-name:’xxx’;/*動(dòng)畫(huà)屬性名,也就是我們前面keyframes定義的動(dòng)畫(huà)名*/ -webkit-animation-duration: 10s;/*動(dòng)畫(huà)持續(xù)時(shí)間*/ -webkit-animation-timing-function: ease-in-out; /*動(dòng)畫(huà)頻率,和transition-timing-function是一樣的*/ -webkit-animation-delay: 2s;/*動(dòng)畫(huà)延遲時(shí)間*/ -webkit-animation-iteration-count: 10;/*定義循環(huán)資料,infinite為無(wú)限次*/ -webkit-animation-direction: alternate;/*定義動(dòng)畫(huà)方式* 回答4:
css3的動(dòng)畫(huà)效果主要是通過(guò)過(guò)渡來(lái)實(shí)現(xiàn)的,用animate來(lái)定義一個(gè)補(bǔ)間動(dòng)畫(huà),瀏覽器會(huì)自動(dòng)根據(jù)設(shè)置的時(shí)間來(lái)進(jìn)行渲染。樓上兩位大神的代碼已經(jīng)做得很完善了,具體效果題主可以自己根據(jù)需要修改
相關(guān)文章:
1. angular.js - webpack怎么做到liveload?2. a標(biāo)簽跨域下載文件能否重命名?3. Android控件和傳值跳轉(zhuǎn)問(wèn)題4. ruby - 為什么無(wú)法啟動(dòng)Rails呢?5. mysql - Access denied for user ’ODBC’@’localhost’ (using password: NO)6. css3 - <img>圓角屬性在手機(jī)瀏覽器顯示不全7. javascript - async/await 與 forEach 問(wèn)題8. html5 - cordova keyboard插件調(diào)取到的鍵盤(pán)是數(shù)字鍵盤(pán)(求解)9. angular.js - angularjs用websocket做聊天功能發(fā)送不出去消息10. mysql取模分表與分表
