溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

怎么用CSS3和table標(biāo)簽實(shí)現(xiàn)一個(gè)圓形軌跡的動(dòng)畫

發(fā)布時(shí)間:2021-06-03 10:48:23 來源:億速云 閱讀:197 作者:小新 欄目:web開發(fā)

小編給大家分享一下怎么用CSS3和table標(biāo)簽實(shí)現(xiàn)一個(gè)圓形軌跡的動(dòng)畫,相信大部分人都還不怎么了解,因此分享這篇文章給大家參考一下,希望大家閱讀完這篇文章后大有收獲,下面讓我們一起去了解一下吧!

html:其實(shí)就是根據(jù)table標(biāo)簽把幾個(gè)實(shí)心圓div進(jìn)行等邊六角形的排布,并放入一個(gè)div容器中,然后利用CSS3的循環(huán)旋轉(zhuǎn)的動(dòng)畫效果對(duì)最外層的div容器進(jìn)行自轉(zhuǎn)實(shí)現(xiàn),當(dāng)然不要忘了把div容器的外邊框設(shè)置圓形弧度的。

<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>開始測(cè)試</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:因?yàn)樵趫A形的軌跡中有6個(gè)實(shí)心圓,分別設(shè)置了不同的類以方便自定義,所以當(dāng)中實(shí)心圓的樣式設(shè)置有重復(fù)的地方,還可以進(jìn)行優(yōu)化,在這就先不處理了

<style>
      /*定義動(dòng)畫*/
      
      @-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;
          }
      }
      
      /*定義外框的樣式*/
      /*調(diào)用動(dòng)畫并設(shè)置動(dòng)畫的參數(shù)*/
      
      .animation_div {
          -webkit-transform-origin:center center;                       /*定義旋轉(zhuǎn)中心點(diǎn)*/
          -webkit-animation:round_animation 15s infinite alternate;     /*infinite alternate表示循環(huán)播放動(dòng)畫*/
          
          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:這里的代碼可以不實(shí)現(xiàn),因?yàn)檫@跟動(dòng)畫的效果無關(guān),是一個(gè)點(diǎn)擊的響應(yīng)事件

angular.module('starter.controllers', [])
    .controller('healthCtrl', function($scope, $location) {
        $scope.clickUrlKey = "BMI";
        $scope.compriseClicked = function(clickUrlKey) {
            $scope.clickUrlKey = clickUrlKey;
        };
    })

效果圖如下:

怎么用CSS3和table標(biāo)簽實(shí)現(xiàn)一個(gè)圓形軌跡的動(dòng)畫

以上是“怎么用CSS3和table標(biāo)簽實(shí)現(xiàn)一個(gè)圓形軌跡的動(dòng)畫”這篇文章的所有內(nèi)容,感謝各位的閱讀!相信大家都有了一定的了解,希望分享的內(nèi)容對(duì)大家有所幫助,如果還想學(xué)習(xí)更多知識(shí),歡迎關(guān)注億速云行業(yè)資訊頻道!

向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI