1,左右移动,自我翻转的圆

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>移动的圆</title>
<style type="text/css">
html, body {
margin: 0;
padding: 0;
background: #ffffff;
outline: none;
letter-spacing: 0
}
.box {
margin: 120px auto 0 auto;
padding: 100px 0 0 0;
width: 680px;
height: 400px;
background: #000000;
}
/* 指定偏移过程中的 */
@keyframes myAnimation {
0% { transform: rotate3d(0, 1, 0, 0deg); margin-left: 0 }
16.67% { transform: rotate3d(0, 1, 0, 60deg); margin-left: 200px }
33.34% { transform: rotate3d(0, 1, 0, 120deg); margin-left: 400px }
50.01% { transform: rotate3d(0, 1, 0, 180deg); margin-left: 600px }
66.68% { transform: rotate3d(0, 1, 0, 240deg); margin-left: 400px }
83.35% { transform: rotate3d(0, 1, 0, 300deg); margin-left: 200px }
100% { transform: rotate3d(0, 1, 0, 360deg); margin-left: 0 }
}
.test {
width: 80px;
height: 80px;
font-size: 16px;
font-weight: bold;
line-height: 80px;
text-align: center;
background: red;
border-radius: 50%;
color: #ffffff;
animation-name: myAnimation; /* 使用的动画名称 */
animation-duration: 2s; /* 一次动画持续时间 */
animation-timing-function: linear; /* 动画变化快慢方式 */
animation-iteration-count: infinite; /* 动画循环的次数,infinite 无限循环 */
}
</style>
</head>
<body>
<div class="box">
<div class="test">文字</div>
</div>
</body>
</html>

效果如下

2,洗牌

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>洗牌</title>
<script src="https://cdn.bootcss.com/jquery/3.3.0/jquery.min.js"></script>
<script src="https://cdn.bootcss.com/vue/2.6.8/vue.min.js"></script>
</head>
<style type="text/css">
#box {
position: relative;
width: 360px;
background: #CCCCCC;
margin: 200px auto 0 auto;
}
.content {
position: absolute;
width: 40px;
height: 40px;
line-height: 40px;
text-align: center;
font-size: 16px;
border: 2px solid white;
box-sizing: border-box;
background: #CCCCCC; transition-property: top, left; /* 这里指动画会接管 top 和 left 属性,一般需要能计量的属性 */
transition-duration: 2s, 2s; /* 这里指当被接管的属性发生变化时,动画过度的完成时间 */
}
.button {
width: 360px;
height: 50px;
line-height: 50px;
text-align: center;
font-size: 19px;
color: white;
background: black;
margin: 400px 0 0 0;
}
</style>
<body>
<div id="box">
<div v-for="(num, index) in numArr"
class="content"
:style="{'top': num.top, 'left': num.left}"
>
{{num.content}}
</div>
<input type="button" value="点击" class="button" @click="shuffle()" />
</div>
</body>
<script type="text/javascript"> // 组装初始化数组
var numArr = [];
for (var i = 0; i < 9; i++) {
for(var j = 0; j < 9; j++){
var num = {};
num.top = i * 40 + 'px';
num.left = j * 40 + 'px';
num.content = (numArr.length + 1) % 9;
numArr.push(num);
}
} // 数组验重
function havaObjArr(obj, arr){
for(var i = 0; i < arr.length; i++){
if(obj.left == arr[i].left && obj.top == arr[i].top){
return true;
}
}
return false;
} // 用 VUE 绑定数据
var vm = new Vue({
data: {
numArr: numArr
},
methods: {
// 重组数组
shuffle() {
var numArr = [];
while (numArr.length < 81) {
var num = {};
num.left = parseInt(Math.random() * 9) * 40 + 'px';
num.top = parseInt(Math.random() * 9) * 40 + 'px';
if (!havaObjArr(num, numArr)) {
num.content = (numArr.length + 1) % 9;
numArr.push(num);
}
}
this.numArr = numArr;
}
}
}).$mount('#box');
</script>
</html>

效果如下

HTML5 动画用 animation transform transition 做的两个例子的更多相关文章

  1. CSS动画:animation、transition、transform、translate

    https://blog.csdn.net/px01ih8/article/details/80780470 一.区分容易混淆的几个属性和值 先区分一下css中的几个属性:animation(动画). ...

  2. animation和transition做动画的区别

    animation做动画,是不需要去触发的,可以定义一开始就执行 transition做动画,是需要人为触发,才能执行的

  3. CSS3 动画实现 animation 和 transition 比较

    在 CSS3 中有两种方式实现动画, 分别是 animation 和 transition, 他们都有以下功能 根据特定 CSS 属性进行动画 设定属性变化的 timing function 设定动画 ...

  4. css 动画 transform transition animation

    1.transform  transform 是通过在浏览器里面让网页元素 移动 旋转 透明 模糊 等方法来实现改变其外观的技术 -webkit-transform : translate(3em,0 ...

  5. CSS3与动画有关的属性transition、animation、transform对比

    最近应公司需求,需要用css3做动画,终于把以前一直傻傻分不清楚的三个属性理解了. 索性在这里进行一个简单的对比,加深自己的记忆. 浏览器兼容性 CSS3 transform 属性 Internet ...

  6. css010 css的transform transition和animation

    css010 css的transform transition和animation 看着没有一个能想起他们是干什么的.. 1.         Transform    Transform(变形) r ...

  7. css 动画(二) transition 过渡 & animation 动画

    前言:这是笔者学习之后自己的理解与整理.如果有错误或者疑问的地方,请大家指正,我会持续更新! translate:平移:是transform的一个属性: transform:变形:是一个静态属性,可以 ...

  8. CSS 中 transform、animation、transition、translate的区别

    在前端页面的开发过程中,经常会碰到这么几个 CSS 属性容易搞混:transform.translate.animation还有transition.下面就针对这几个 CSS 属性做一个对比,辨别这几 ...

  9. css笔记——区分css3中的transform transition animation

    出处:http://blog.csdn.net/dyllove98/article/details/8957232   CSS3中和动画有关的属性有三个  transform. transition  ...

随机推荐

  1. C++ 凸包生成算法

    由于我的极差记忆力,我打算把这个破玩意先记下来.因为以后会有改动(Delaunay三角网生成算法),我不想把一个好的东西改坏了... 好吧-- 凸包生成算法,: 1.先在指定的宽(width)高(he ...

  2. delphi Parallel 之 TTask 初试

    unit Unit1; interface uses Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System ...

  3. 1、编写一个简单Makefile模板

    一.Makefile简介 一个工程中的源文件不计其数,其按类型.功能.模块分别放在若干个目录中,makefile定义了一系列的规则来指定,哪些文件需要先编译,哪些文件需要后编译,哪些文件需要重新编译, ...

  4. Azure CosmosDB (11) MongoDB概念

    <Windows Azure Platform 系列文章目录> Azure Cosmos DB兼容MongoDB的API,下表将帮助我们更容易理解MongoDB中的一些概念: SQL概念 ...

  5. 【C++】类中this指针的理解

    转自 苦涩的茶https://www.cnblogs.com/liushui-sky/p/5802981.html C++类中this指针的理解 先要理解class的意思.class应该理解为一种类型 ...

  6. <ROS> message_filters 对齐多种传感器数据的时间戳

    联合标定三维雷达和IMU,第一步要先对齐两种传感信息的时间戳. ros官网提供了message_filters用于对齐多种传感信息的时间戳. http://wiki.ros.org/message_f ...

  7. bash: ./LM35_make_fs: Permission denied 解决办法

    执行命令的时候 ./LM35_make_fs 遇到 permission denied, bash: ./LM35_make_fs: Permission denied权限的问题,可以运行 ls -l ...

  8. Java Socket NIO

    服务端: public class NIOServer { private static final String HOST = "localhost"; private stat ...

  9. python 函数内使用自己的函数名

    def p(): import sys print sys._getframe(1).f_code.co_name def f(): p() def f1(): p() if __name__ == ...

  10. 基于STM8的GPIO操作---STM8-第一章

    1. 综诉 也许单片机在你看来是一件不太容易的事,但据我所知,单片机,无非就是控制它的GPIO口,所以可以看出,学会如何操作控制GPIO口对使用单片机来说是很重要的一件事. 在装载STM8的单片机中, ...