anime实现16方块动画变换效果

代码语言:html

所属分类:动画

代码描述:anime实现16方块动画变换效果

代码标签: 方块 动画 变换 效果

下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开


<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">

<style>
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}
.animation-example {
  position: relative;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
}
.animation-example > .set-1 {
  height: 60vmin;
  width: 60vmin;
  position: absolute;
  top: 50%;
  left: 0%;
  -webkit-transform: translateX(20%) translateY(-50%) rotate(45deg) scale(1);
          transform: translateX(20%) translateY(-50%) rotate(45deg) scale(1);
}
.animation-example > .set-1 > .block {
  display: inline-block;
  position: relative;
  float: left;
  height: 5vmin;
  width: 5vmin;
  margin: 5vmin;
  background: #EA638C;
}
.animation-example > .set-2 {
  height: 60vmin;
  width: 60vmin;
  position: absolute;
  top: 50%;
  left: 150%;
  -webkit-transform: translateX(-50%) translateY(-50%) rotate(0) scale(0);
          transform: translateX(-50%) translateY(-50%) rotate(0) scale(0);
}
.animation-example > .set-2 > .block {
  display: inline-block;
  position: relative;
  float: left;
  height: 5vmin;
  width: 5vmin;
  margin: 5vmin;
  background: #FFFFFF;
}
.animation-example > .dots {
  position: absolute;
  bottom: 32px;
  left: 50%;
  -webkit-transform: translateX(-50%);
          transform: translateX(-50%);
  width: 100%;
  text-align: center;
}
.animation-example > .dots > .dot {
  position: relative;
  display: inline-block;
  margin: 0 16px;
  height: 16px;
  width: 16px;
  border-radius: 50%;
  background: #000000;
}
.animation-example > .dots > .dot::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  height: 10px;
  width: 10px;
  border-radius: 50%;
  -webkit-transform: translateX(-50%) translateY(-50%);
          transform: translateX(-50%) translateY(-50%);
  background: #FFFFFF;
  opacity: 0;
  -webkit-transition: opacity 0.5s ease-in-out;
  transition: opacity 0.5s ease-in-out;
  -webkit-transition-delay: 0.3s;
          transition-delay: 0.3s;
}
.animation-example > .dots > .dot.-active::after {
  opacity: 1;
}
</style>

</head>
<body translate="no">
<div class='animation-example'>
<div class='set-1'>
<div class='block'></div>
<div class='block'></div>
<div class='block'></div>
<div class='block'></div>
<div class='block'></div>
<div class='block'></div>
<div class='block'></div>
<div class='block'></div>
<div class='block'></div>
<div class='block'></div>
<div class='block'></div>
<div class='block'></div>
<div class='block'></div>
<div class='block'></div>
<div class='block'></div>
<div class='block'></div>
</div>
<div class='set-2'>
<div class='block'></div>
<div class='block'></div>
<div class='block'></div>
<div class='block'></div>
<div class='block'></div>
<div class='block'></div>
<div class='block'></div>
<div class='block'></div>
<div class='block'></div>
<div class='block'></div>
<div class='block'></div>
<div class='block'></div>
 <div class='block'></div>
<div class='block'></div>
<div class='block'></div>
<div class='block'></div>
</div>
<div class='dots'>
<div class='dot -active'></div>
<div class='dot'></div>
<div class='dot'></div>
<div class='dot'></div>
<div class='dot'></div>
</div>
</div>
<script type="text/javascript" src="http://repo.bfw.wiki/bfwrepo/js/anime-min.js"></script>
<script >
// 1. Get elements

const example = document.querySelector('.animation-example');
const set1 = example.querySelector('.set-1');
const set2 = example.querySelector('.set-2');
const blocks1 = set1.querySelectorAll('.block');
const blocks2 = set2.querySelectorAll('.block');
const dots = example.querySelectorAll('.dot');


// 2. Set the states

const states = [
// #1
{
  randomRotateMod: 0,
  example: {
    background: 'rgb(255,255,255)' },

  set1: {
    top: '50%',
    left: '0%',
    translateX: '20%',
    translateY: '-50%',
    rotate: '45deg',
    scale: '1' },

  set2: {
    top: '50%',
    left: '150%',
    translateX: '-50%',
    translateY: '-50%',
    rotate: '0deg',
    scale: '0' },

  blocks1: {
    scale: '0.5' },

  blocks2: {
    scale: '1' } },



/.........完整代码请登录后点击上方下载按钮下载查看

网友评论0