纯css实现图片闪屏故障动画特效

代码语言:html

所属分类:视觉差异

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

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

<title> Image glitch effect</title>
<link rel='stylesheet' href='https://fonts.googleapis.com/css?family=Bungee'>
<style>
      :root {
  --color-text: #fff;
  --color-bg: #000;
  --color-link: #f9d77e;
  --color-link-hover: #fff;
  --color-info: #efc453;
  --glitch-width: 100vw;
  --glitch-height: 100vh;
  --gap-horizontal: 10px;
  --gap-vertical: 5px;
  --time-anim: 4s;
  --delay-anim: 2s;
  --blend-mode-1: none;
  --blend-mode-2: none;
  --blend-mode-3: none;
  --blend-mode-4: none;
  --blend-mode-5: overlay;
  --blend-color-1: transparent;
  --blend-color-2: transparent;
  --blend-color-3: transparent;
  --blend-color-4: transparent;
  --blend-color-5: #af4949;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  background-color: #1D1E22;
  margin: 0;
  padding: 0;
}

.glitch {
  width: 100vw;
  height: 100vh;
  max-width: 100%;
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
}
.glitch .glitch__item {
  background: url("http://repo.bfw.wiki/bfwrepo/image/slicebox/4.jpg") no-repeat 50% 50%/cover;
  height: 100%;
  width: 100%;
  top: 0;
  left: 0;
  position: absolute;
}
.glitch .glitch__item:nth-child(n+2) {
  opacity: 0;
  animation-duration: var(--time-anim);
  animation-delay: var(--delay-anim);
  animation-timing-function: linear;
  animation-iteration-count: infinite;
}
.glitch .glitch__item:nth-child(2) {
  background-color: var(--blend-color-2);
  background-blend-mode: var(--blend-mode-2);
  animation-name: glitch-anim-2;
}
.glitch .glitch__item:nth-child(2) {
  background-color: var(--blend-color-3);
  background-blend-mode: var(--blend-mode-3);
  animation-name: glitch-anim-3;
}
.glitch .glitch__item:nth-child(4) {
  background-color: var(--blend-color-4);
  background-blend-mode: var(--blend-mode-4);
  animation-name: glitch-anim-4;
}
.glitch .glitch__item:nth-child(5) {
  background-color: var(--blend-color-5);
  background-blend-mode: var(--blend-mode-5);
  animation-name: glitch-anim-flash;
}
@keyframes glitch-anim-flash {
  0%,5% {
    opacity: 0.2;
    transform: translate3d(var(--glitch-horizontal), var(--glitch-height), 0);
  }
  5.5%,100% {
    opacity: 0;
    transform: translate3d(0, 0, 0);
  }
}
.glitch .glitch__title {
  font-family: 'Bungee', cursive;
  font-size: 100px;
  color: #ffffff;
  position: relative;
  text-transform: uppercase;
}
.glitch .glitch__title:before, .glitch .glitch__title:after {
  content: 'GLITCH';
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
}
.glitch .glitch__title:before {
  left: 2px;
  text-shadow: -1px 0 #00ffea;
  clip: rect(24px, 550px, 90px, 0);
  animation: glitch-anim 2s linear infinite alternate-reverse;
}
.glitch .glitch__title:after {
  left: -2px;
  text-shadow: -1px 0 #fe3a7f;
  clip: rect(85px, 550px, 140px, 0);
  animation: glitch-anim 2s 1s linear infinite alternate-reverse;
}
@keyframes glitch-anim {
  0% {
    clip: rect(25px, 9999px, 80px, 0);
  }
  5% {
    clip: rect(57px, 9999px, 68px, 0);
  }
  10% {
    clip: rect(68px, 9999px, 66px, 0);
  }
  15% {
    clip: rect(127px, 9999px, 155px, 0);
  }
  20% {
    clip: rect(71px, 9999px, 10px, 0);
  }
  25% {
    clip: rect(52px, 9999px, 6px, 0);
  }
  30% {
    clip: rect(60px, 9999px, 166px, 0);
  }
  35% {
    clip: rect(36px, 9999px, 114px, 0);
  }
  40% {
    clip: rect(102px, 9999px, 84px, 0);
  }
  45% {
    clip: rect(8px, 9999px, 109px, 0);
  }
  50% {
    clip: rect(115px, 9999px, 139px, 0);
  }
  55% {
    clip: rect(90px, 9999px, 5px, 0);
  }
  60% {
    cli.........完整代码请登录后点击上方下载按钮下载查看

网友评论0