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. mysql儲存json錯誤2. mysql - 這種分級一對多,且分級不平衡的模型該怎么設計表?3. 在mybatis使用mysql的ON DUPLICATE KEY UPDATE語法實現存在即更新應該使用哪個標簽?4. mac OSX10.12.4 (16E195)下Mysql 5.7.18找不到配置文件my.cnf5. Navicat for mysql 中以json格式儲存的數據存在大量反斜杠,如何去除?6. mysql - 表名稱前綴到底有啥用?7. mysql - 數據庫表中,兩個表互為外鍵參考如何解決8. mysql - 數據庫建字段,默認值空和empty string有什么區別 1109. mysql - 怎么生成這個sql表?10. php - 公眾號文章底部的小程序二維碼如何統計?
