css3 - css做動畫效果
問題描述
把紅色框內做成那種來回動畫效果怎么做啊?
問題解答
回答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>
運行一下上面的代碼,改于w3school。
鏈接為:http://www.w3school.com.cn/cs...
回答2:給你個鏈接 自己對著改參數
回答3:給那個三角圖片 擺好位置后, 用類去控制動作。
比如
.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); } } // 補充說明: -webkit-animation-name:’xxx’;/*動畫屬性名,也就是我們前面keyframes定義的動畫名*/ -webkit-animation-duration: 10s;/*動畫持續時間*/ -webkit-animation-timing-function: ease-in-out; /*動畫頻率,和transition-timing-function是一樣的*/ -webkit-animation-delay: 2s;/*動畫延遲時間*/ -webkit-animation-iteration-count: 10;/*定義循環資料,infinite為無限次*/ -webkit-animation-direction: alternate;/*定義動畫方式* 回答4:
css3的動畫效果主要是通過過渡來實現的,用animate來定義一個補間動畫,瀏覽器會自動根據設置的時間來進行渲染。樓上兩位大神的代碼已經做得很完善了,具體效果題主可以自己根據需要修改
相關文章:
1. python - beautifulsoup獲取網頁內容的問題2. Docker for Mac 創建的dnsmasq容器連不上/不工作的問題3. docker鏡像push報錯4. docker - 如何修改運行中容器的配置5. docker-machine添加一個已有的docker主機問題6. fragment - android webView 返回后怎么禁止重新渲染?7. docker不顯示端口映射呢?8. android studio總是在processes running好久9. dockerfile - [docker build image失敗- npm install]10. angular.js - Angular 2 + Django構建的Web應用, 如何合理搭配 ?
