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. jquery案例

    调用js成员 <!DOCTYPE html><html xmlns="http://www.w3.org/1999/xhtml"><head>& ...

  2. maya_关于脚本编辑器导入python模块

    import sys for p in sys.path: print p rigDir = 'C:\Users\lenovo\Documents\maya\scripts\python\rigLib ...

  3. Css之 间距初始化

    粗暴初始化: * {margin:0;padding:0;border:0px none;} 优化初始化: /*css reset code */ /**** 文字大小初始化,使1em=10px ** ...

  4. imp 导入报错

    imp user/passwd file=/data/oracle/oraclesetup/passwd.dmp 报错: Export file created by EXPORT:V11.02.00 ...

  5. py-day4-3 python 内置函数 man和mix的高级使用

    ### man和mix的高级使用 age_dic={'xiaoma':18,'zhangfei':20,'xiaowang':36,'lihao':13,} print(max(age_dic.val ...

  6. Oracle触发bug(cursor: mutex S),造成数据库服务器CPU接近100%---SQL子游标多版本问题

    问题现象: 项目反馈系统反应非常缓慢,数据库服务器CPU接近100%! INSERT INTO GSPAudit1712(ID,TypeID,CategoryID,DateTime,UserID,Us ...

  7. 使用phpunit测试yaf项目操作步骤

    yaf + phpunit 使用phpunit对yaf进行测试的核心在于bootstrip文件的配置. *1. 首先在项目目录下创建tests文件,并在tests中创建phpunit.xml < ...

  8. 如何创建 SVN 服务器,并搭建自己的 SVN 仓库 如何将代码工程添加到VisualSVN Server里面管理

    如何创建 SVN 服务器,并搭建自己的 SVN 仓库,附链接: https://jingyan.baidu.com/article/6b97984dca0d9c1ca3b0bf40.html 如何将代 ...

  9. Element UI toggleRowExpansion用法

    背景: 官方说明文档没有具体代码示例 一.官方文档 方法名: toggleRowExpansion 说明: 用于可展开表格,切换某一行的展开状态,如果使用了第二个参数,则是设置这一行展开与否(expa ...

  10. c++ map 注意事项

    1.  往map里面插入元素: 下标方式[]:    map[key] = value; 调用insert:       map.insert(make_pair(key, value)); 下标方式 ...