纯css实现海底鱼儿游玩动画效果

代码语言:html

所属分类:动画

代码描述:纯css实现海底鱼儿游玩动画效果

代码标签: 海底 鱼儿 游玩 动画 效果

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


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

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

body {
  background-color: #bdf;
  min-height: 100vh;
}

.fish {
  position: fixed;
  top: 200px;
  width: 110px;
  height: 90px;
  background-color: var(--fColor);
  background-image: -webkit-gradient(linear, right top, left top, from(var(--fColor)), color-stop(50%, transparent)), -webkit-gradient(linear, left top, left bottom, from(transparent), color-stop(30%, rgba(255, 255, 255, 0.3)), to(rgba(0, 0, 0, 0.3)));
  background-image: linear-gradient(270deg, var(--fColor), transparent 50%), linear-gradient(transparent, rgba(255, 255, 255, 0.3) 30%, rgba(0, 0, 0, 0.3));
  border-radius: 50%;
  -webkit-transform: rotate(30deg) translateX(-50%);
          transform: rotate(30deg) translateX(-50%);
  -webkit-filter: blur(1px) drop-shadow(0 0 10px rgba(0, 0, 0, 0.25));
          filter: blur(1px) drop-shadow(0 0 10px rgba(0, 0, 0, 0.25));
  -webkit-animation: swim 20s var(--fishDelay) linear infinite;
          animation: swim 20s var(--fishDelay) linear infinite;
}
.fish:nth-child(1) {
  --swimX: -30%;
  --fishDelay: -10s;
  --fColor: #880E4F;
}
.fish:nth-child(2) {
  --swimX: -10%;
  --fishDelay: -2s;
  --fColor: #B71C1C;
}
.fish:nth-child(3) {
  --swimX: 10%;
  --fishDelay: -12s;
  --fColor: #BF360C;
}
.fish:nth-child(4) {
  --swimX: 30%;
  --fishDelay: -4s;
  --fColor: #E65100;
}
.fish:nth-child(5) {
  --swimX: 50%;
  --fishDelay: -14s;
  --fColor: #FF6F00;
}
.fish:nth-child(6) {
  --swimX: 70%;
  --fishDelay: -6s;
  --fColor: #F57F17;
}
.fish:nth-child(7) {
  --swimX: 90%;
  --fishDelay: -16s;
  --fColor: #827717;
}
.fish:nth-child(8) {
  --swimX: 110%;
  --fishDelay: -8s;
  --fColor: #33691E;
}
.fish:nth-child(9) {
  --swimX: 130%;
  --fishDelay: 0s;
  --fColor: #1B5E20;
}
@-webkit-keyframes swim {
  from {
    left: calc(50% - 1400px);
    top: calc(var(--swimX) - 700px);
  }
  to {
    left: calc(50% + 1400px);
    top: calc(var(--swimX) + 700px);
  }
}
@keyframes swim {
  from {
    left: calc(50% - 1400px);
    top: calc(var(--swimX) - 700px);
  }
  to {
    left: calc(50% + 1400px);
    top: calc(var(--swimX) + 700px);
  }
}
.fish .eyes {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  overflow: hidden;
}
.fish .eyes::before, .fish .eyes::after {
  content: '';
  position: absolute;
  left: 55%;
  width: 20px;
  height: 20px;
  background-color: teal;
  border-radius: 50%;
  background-color: rgba(0, 0, 0, 0.2);
  border: 5px solid rgba(255, 255, 255, 0.2);
}
.fish .eyes::before {
  top: -15%;
}
.fish .eyes::after {
  bottom: -15%;
}
.fish [class|=link] {
  position: absolute;
  top: 50%;
  right: 50%;
  width: 80px;
  height: 100px;
  background-color: var(--fColor);
  bac.........完整代码请登录后点击上方下载按钮下载查看

网友评论0