心跳心电图动画效果

代码语言:html

所属分类:动画

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

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

<style>
/*
--d for the offset-path used for the circle
--animation describing the properties shared by the circle and path
*/
:root {
  --d: "M 0 0 h 300";
  --animation: 4s cubic-bezier(0.445, 0.05, 0.55, 0.95) infinite forwards;
}

* {
  box-sizing: border-box;
  padding: 0;
  margin: 0;
}
body {
  min-height: 100vh;
  display: flex;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' opacity='0.25' viewBox='0 0 50 50'%3E%3Cpath d='M 0 0 h 50 v 50' fill='none' stroke='hsl(140, 75%25, 50%25)' stroke-width='1' stroke-linecap='square' stroke-linejoin='square' /%3E%3C/svg%3E"), hsl(140, 80%, 4%);
  background-size: 25px;
  color: hsl(150, 75%, 90%);
}
svg {
  margin: auto;
  width: 300px;
  height: auto;
  display: block;
}

/* animate the circle to follow the path described by the custom property */
svg circle {
  offset-path: path(var(--d));
  offset-distance: 0%;
  animation: var(--animation);
  animation-name: increaseOffset;
}

svg path {
  stroke-dashoffset: 1;
  stroke-dasharray: 1;
  animation: var(--animation);
  animation-name: removeOffset;
}

@keyframes increaseOffset {
  to {
    offset-distanc.........完整代码请登录后点击上方下载按钮下载查看

网友评论0