用CSS3和table标签实现一个圆形轨迹的动画的示例代码


Posted in HTML / CSS onJanuary 17, 2019

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>
    
    <h3>clickUrlKey:{{clickUrlKey}}</h3>

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标签实现一个圆形轨迹的动画的示例代码

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持三水点靠木。

HTML / CSS 相关文章推荐
css3 中实现炫酷的loading效果
Apr 26 HTML / CSS
css3.0 图形构成实例练习一
Mar 19 HTML / CSS
CSS3 :nth-child()伪类选择器实现奇偶行显示不同样式
Nov 05 HTML / CSS
css3与html5实现响应式导航菜单(导航栏)效果分享
Feb 12 HTML / CSS
纯CSS实现颜色渐变效果(包含环形渐变、线性渐变、彩虹效果等)
May 07 HTML / CSS
CSS3中利用animation属性创建雪花飘落特效
May 14 HTML / CSS
利用Bootstrap实现漂亮简洁的CSS3价格表实例源码
Mar 02 HTML / CSS
html5自带表单验证体验优化及提示气泡修改功能
Sep 12 HTML / CSS
HTML5边玩边学(2)基础绘图实现方法
Sep 21 HTML / CSS
HTML5中5个简单实用的API
Apr 28 HTML / CSS
HTML5 Canvas基本线条绘制的实例教程
Mar 17 HTML / CSS
html5实现图片转圈的动画效果——让页面动起来
Oct 16 HTML / CSS
简单几步用纯CSS3实现3D翻转效果
Jan 17 #HTML / CSS
css3实现3D文本悬停改变效果的示例代码
Jan 16 #HTML / CSS
css3实现元素环绕中心点布局的方法示例
Jan 15 #HTML / CSS
CSS3改变浏览器滚动条样式
Jan 04 #HTML / CSS
浅谈CSS3 动画卡顿解决方案
Jan 02 #HTML / CSS
纯CSS3实现漂亮的input输入框动画样式库(Text input love)
Dec 29 #HTML / CSS
10分钟入门CSS3 Animation
Dec 25 #HTML / CSS
You might like
通过html表格发电子邮件
2006/10/09 PHP
php如何实现只替换一次或N次
2015/10/29 PHP
PHP三种方式实现链式操作详解
2017/01/21 PHP
Yii2.0实现生成二维码功能实例
2017/10/24 PHP
PHP中rename()函数的妙用讲解
2019/02/28 PHP
新手入门常用代码集锦
2007/01/11 Javascript
IE7提供XMLHttpRequest对象为兼容
2007/03/08 Javascript
jQuery+CSS 实现的超Sexy下拉菜单
2010/01/17 Javascript
Jquery 获取checkbox的checked问题
2011/11/16 Javascript
javascript中动态函数用法实例分析
2015/05/14 Javascript
Eclipse编辑jsp、js文件时卡死现象的解决办法汇总
2016/02/02 Javascript
Js的Array数组对象详解
2016/02/22 Javascript
JS实现图片平面旋转的方法
2016/03/01 Javascript
JavaScript高级程序设计(第三版)学习笔记6、7章
2016/03/11 Javascript
基于zepto.js实现手机相册功能
2017/07/11 Javascript
SpringMVC简单整合Angular2的示例
2017/07/31 Javascript
Angular ElementRef简介及其使用
2018/10/01 Javascript
Vue项目打包编译优化方案
2020/09/16 Javascript
JavaScript实现网页下拉菜单效果
2020/11/20 Javascript
python3图片转换二进制存入mysql
2013/12/06 Python
Python遍历指定文件及文件夹的方法
2015/05/09 Python
Python3中使用PyMongo的方法详解
2017/07/28 Python
Django objects的查询结果转化为json的三种方式的方法
2018/11/07 Python
python根据url地址下载小文件的实例
2018/12/18 Python
python移位运算的实现
2019/07/15 Python
Python3 io文本及原始流I/O工具用法详解
2020/03/23 Python
基于python实现可视化生成二维码工具
2020/07/08 Python
Django restful framework生成API文档过程详解
2020/11/12 Python
Smashbox英国官网:美国知名彩妆品牌
2017/11/13 全球购物
非功能性需求都包括哪些方面
2013/10/29 面试题
大学生四个方面的自我评价
2013/09/19 职场文书
幼儿教师师德演讲稿
2014/05/06 职场文书
求职信内容怎么写
2014/05/26 职场文书
2014年秋季开学典礼致辞
2014/08/02 职场文书
无犯罪记录证明
2014/09/19 职场文书
JavaScript模拟实现网易云轮播效果
2022/04/04 Javascript