您好,登錄后才能下訂單哦!
小編給大家分享一下怎么用CSS3和table標簽實現一個圓形軌跡的動畫,相信大部分人都還不怎么了解,因此分享這篇文章給大家參考一下,希望大家閱讀完這篇文章后大有收獲,下面讓我們一起去了解一下吧!
html:其實就是根據table標簽把幾個實心圓div進行等邊六角形的排布,并放入一個div容器中,然后利用CSS3的循環旋轉的動畫效果對最外層的div容器進行自轉實現,當然不要忘了把div容器的外邊框設置圓形弧度的。
<div class="animation_div"> <table class="table_class"> <tr> <td></td> <td> <div class="BMI" ng-click="compriseClicked('BMI')" ng-class="{isSelected:clickUrlKey=='BMI'}"> <strong>BMI</strong> </div> </td> <td></td> <td> <div class="color_blind" ng-click="compriseClicked('color_blind')" ng-class="{isSelected:clickUrlKey=='color_blind'}"> <strong>色盲色弱</strong> </div> </td> <td></td> </tr> <tr> <td> <div class="space_div"></div> </td> </tr> <tr> <td> <div class="HR" ng-click="compriseClicked('HR')" ng-class="{isSelected:clickUrlKey=='HR'}"> <strong>心率</strong> </div> </td> <td></td> <td> <a href="#/app/custom_made/counselor/{{clickUrlKey}}" style="text-decoration: none; color: black;"> <div class="start_test"> <strong>開始測試</strong> </div> </a> </td> <td></td> <td> <div class="fat_content" ng-click="compriseClicked('fat_content')" ng-class="{isSelected:clickUrlKey=='fat_content'}"> <strong>脂肪含量</strong> </div> </td> </tr> <tr> <td> <div class="space_div"></div> </td> </tr> <tr> <td></td> <td> <div class="WHR" ng-click="compriseClicked('WHR')" ng-class="{isSelected:clickUrlKey=='WHR'}"> <strong>腰臀比</strong> </div> </td> <td></td> <td> <div class="safe_period" ng-click="compriseClicked('safe_period')" ng-class="{isSelected:clickUrlKey=='safe_period'}"> <strong>安全期</strong> </div> </td> <td></td> </tr> </table> </div> <h4>clickUrlKey:{{clickUrlKey}}</h4>
css:因為在圓形的軌跡中有6個實心圓,分別設置了不同的類以方便自定義,所以當中實心圓的樣式設置有重復的地方,還可以進行優化,在這就先不處理了
<style> /*定義動畫*/ @-webkit-keyframes round_animation { 0%{ -webkit-transform:rotate(0deg); width:260px; height:260px; } 100%{ -webkit-transform:rotate(360deg); width:260px; height:260px; left:0px; top:0px; } } /*定義外框的樣式*/ /*調用動畫并設置動畫的參數*/ .animation_div { -webkit-transform-origin:center center; /*定義旋轉中心點*/ -webkit-animation:round_animation 15s infinite alternate; /*infinite alternate表示循環播放動畫*/ margin: 60px auto; width:260px; height:260px; border: 1px solid black; border-radius: 130px; left:0px; top:0px; } .animation_div strong { font-size: 12px; } .BMI { width: 50px; height: 50px; background-color: orange; border-radius: 100px; text-align: center; /*文字垂直居中*/ vertical-align: middle; line-height: 50px; } .color_blind { width: 50px; height: 50px; background-color: green; border-radius: 100px; text-align: center; /*文字垂直居中*/ vertical-align: middle; line-height: 50px; } .HR{ margin-left: -15px; width: 50px; height: 50px; background-color: blue; border-radius: 100px; text-align: center; /*文字垂直居中*/ vertical-align: middle; line-height: 50px; } .start_test { width: 60px; height: 60px; background-color: red; border-radius: 100px; text-align: center; /*文字垂直居中*/ vertical-align: middle; line-height: 50px; } .fat_content { margin-left: 15px; width: 50px; height: 50px; background-color: gray; border-radius: 100px; text-align: center; /*文字垂直居中*/ vertical-align: middle; line-height: 50px; } .WHR { width: 50px; height: 50px; background-color: purple; border-radius: 100px; text-align: center; /*文字垂直居中*/ vertical-align: middle; line-height: 50px; } .safe_period { width: 50px; height: 50px; background-color: yellow; border-radius: 100px; text-align: center; /*文字垂直居中*/ vertical-align: middle; line-height: 50px; } .space_div { width: 50px; height: 50px; background-color: clear; border-radius: 100px; } .rightmenu_btn { height: 60px; float: none; } .rightmenu_btn button { margin-top: 50px; width: 20px; height: 60px; border: 1px solid rgb(221, 221, 221); border-right: 0px; float: right; } .isSelected { border: 1px solid red; } </style>
JS:這里的代碼可以不實現,因為這跟動畫的效果無關,是一個點擊的響應事件
angular.module('starter.controllers', []) .controller('healthCtrl', function($scope, $location) { $scope.clickUrlKey = "BMI"; $scope.compriseClicked = function(clickUrlKey) { $scope.clickUrlKey = clickUrlKey; }; })
效果圖如下:
以上是“怎么用CSS3和table標簽實現一個圓形軌跡的動畫”這篇文章的所有內容,感謝各位的閱讀!相信大家都有了一定的了解,希望分享的內容對大家有所幫助,如果還想學習更多知識,歡迎關注億速云行業資訊頻道!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。