div+css实现圆形分割成方块动画效果代码

代码语言:html

所属分类:动画

代码描述:div+css实现圆形分割成方块动画效果代码

代码标签: div css 圆形 分割 方块 动画

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


<!DOCTYPE html>
<html lang="en" >

<head>

  <meta charset="UTF-8">

  
  
  
<style>
*, *::before, *::after {
  padding: 0;
  margin: 0 auto;
  box-sizing: border-box;
}

body {
  background-image: radial-gradient(circle, #000, #010 42em);
  min-height: 100vh;
  display: grid;
  place-items: center;
  overflow: hidden;
}

.frame {
  border: 4px solid aquamarine;
  background-color: #222;
  overflow: hidden;
  border-radius: 50%;
  font-size: 36px;
  -webkit-animation: frameRotate 30s infinite linear;
          animation: frameRotate 30s infinite linear;
  filter: blur(6px) contrast(6);
}
@-webkit-keyframes frameRotate {
  to {
    transform: rotate(90deg);
  }
}
@keyframes frameRotate {
  to {
    transform: rotate(90deg);
  }
}

.grid {
  display: grid;
  place-items: center;
  grid-template-columns: repeat(8, 1em);
  grid-template-rows: repeat(8, 1em);
  gap: 1em;
  padding: 1em;
  -webkit-animation: gridScale 5s infinite linear;
          animation: gridScale 5s infinite linear;
}
@-webkit-keyframes gridScale {
  to {
    transform: scale(2);
  }
}
@keyframes gridScale {
  to {
    transform: scale(2);
  }
}

.sqr {
  width: 1em;
  height: 1em;
  background-color: aquamarine;
  -webkit-animation: sqrTransform 5s infinite ease-in-out;
          animation: sqrTransform 5s infinite ease-in-out;
}
@-webkit-keyframes sqrTransform {
  0% {
    transform: translate(var(--tx, 0), var(--ty, 0));
  }
  30%, 100% {
    transform: translate(0, 0);
  }
}
@keyframes sqrTransform {
  0% {
    transform: translate(var(--tx, 0), var(--ty, 0));
  }
  30%, 100% {
    transform: translate(0, 0);
  }
}
.sqr:nth-child(2n+1) {
  --tx: 0.5em;
}
.sqr:nth-child(2n+2) {
  --tx: -0.5em;
}
.sqr:nth-child(16n+1) {
  --ty: 0.5em;
}
.sqr:nth-child(16n+9) {
  --ty: -0.5em;
}
.sqr:nth-child(16n+2) {
  --ty: 0.5em;
}
.sqr:nth-child(16n+10) {
  --ty: -0.5em;
}
.sqr:nth-child(16n+3) {
  --ty: 0.5em;
}
.sqr:nth-child(16n+11) {
  --ty: -0.5em;
}
.sqr:nth-child(16n+4) {
  --ty: 0.5em;
}
.sqr:nth-child(16n+12) {
  --ty: -0.5em;
}
.sqr:nth-child(16n+5) {
  --ty: 0.5em;
}
.sqr:nth-child(16n+13) {
  --ty: -0.5em;
}
.sqr:nth-child(16n+6) {
  --ty: 0.5em;
}
.sqr:nth-child(16n+14) {
  --ty: -0.5em;
}
.sqr:nth-child(16n+7) {
  --ty: 0.5em;
}
.sqr:nth-child(16n+15) {
  --ty: -0.5em;
}
.sqr:nth-child(16n+8) {
  --ty: 0.5em;
}
.sqr:nth-child(16n+16) {
  --ty: -0.5em;
}
</style>

</head>

<body >
  <div class="frame">
  <div class="grid">
    <div class="sqr"></div>
    <div class="sqr"></div>
    <div class="sqr"></div>
    <div class="sqr"></div>
    <div class="sqr"></div>
    <div class="sqr"></div>
    <div class=.........完整代码请登录后点击上方下载按钮下载查看

网友评论0