css3 - css做動畫效果
問題描述
把紅色框內(nèi)做成那種來回動畫效果怎么做?。?/p>
問題解答
回答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è)鏈接 自己對著改參數(shù)
回答3:給那個(gè)三角圖片 擺好位置后, 用類去控制動作。
比如
.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ǔ)充說明: -webkit-animation-name:’xxx’;/*動畫屬性名,也就是我們前面keyframes定義的動畫名*/ -webkit-animation-duration: 10s;/*動畫持續(xù)時(shí)間*/ -webkit-animation-timing-function: ease-in-out; /*動畫頻率,和transition-timing-function是一樣的*/ -webkit-animation-delay: 2s;/*動畫延遲時(shí)間*/ -webkit-animation-iteration-count: 10;/*定義循環(huán)資料,infinite為無限次*/ -webkit-animation-direction: alternate;/*定義動畫方式* 回答4:
css3的動畫效果主要是通過過渡來實(shí)現(xiàn)的,用animate來定義一個(gè)補(bǔ)間動畫,瀏覽器會自動根據(jù)設(shè)置的時(shí)間來進(jìn)行渲染。樓上兩位大神的代碼已經(jīng)做得很完善了,具體效果題主可以自己根據(jù)需要修改
相關(guān)文章:
1. python - scrapy url去重2. MySQL主鍵沖突時(shí)的更新操作和替換操作在功能上有什么差別(如圖)3. node.js - 微信小程序websocket連接問題4. python執(zhí)行cmd命令,怎么讓他執(zhí)行類似Ctrl+C效果將其結(jié)束命令?5. 實(shí)現(xiàn)bing搜索工具urlAPI提交6. Python中使用超長的List導(dǎo)致內(nèi)存占用過大7. python - Django有哪些成功項(xiàng)目?8. ios - 類似微博首頁,一張圖的時(shí)候是如何確定圖大小的?9. 數(shù)據(jù)庫 - Mysql的存儲過程真的是個(gè)坑!求助下面的存儲過程哪里錯(cuò)啦,實(shí)在是找不到哪里的問題了。10. 鏈接圖片時(shí),鏈接不成功
