css-doodle实现元宵节孔明灯飘动动画效果代码

代码语言:html

所属分类:动画

代码描述:css-doodle实现元宵节孔明灯飘动动画效果代码

代码标签: css-doodle 元宵节 孔明灯 飘动

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


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

<head>

  <meta charset="UTF-8">
  


  <link rel='stylesheet' href='https://fonts.googleapis.com/css2?family=Ma+Shan+Zheng&amp;display=swap'>
  
<style>
@charset "UTF-8";
html,
body {
  height: 100%;
  margin: 0;
}

body {
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: "Ma Shan Zheng", cursive;
}

graph {
  position: relative;
  background: #fff;
  box-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.1), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
  border-radius: 4px;
}

graph::after {
  content: "今年元夜时";
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(calc(-50% + 3vmin), -50%);
  font-size: 2.5vmin;
  text-align: center;
  white-space: nowrap;
  color: rgba(255, 255, 255, 0.8);
  letter-spacing: 6vmin;
}
</style>



</head>

<body>
  <graph>
  <css-doodle click-to-update>
    :doodle {
      @grid: 16x10 / 80vmin 80vmin;
      @max-size: 800px 800px;
      overflow: hidden;
      background: linear-gradient(#1B0F0E, #521E18);
      border-radius: 4px;
    }
    background-image: radial-gradient(circle at @r(45, 55)% 100%, #fff 0%, #fff @r(5, 10)%, #F7E076 20%, #ffc88a 30%, #ebd15b 40%, #c57010 80%);
    border-radius: @r(0, 4)px;

    --rotate: @r(±15)deg;
    --translate-x: @r(±20)%;
    --translate-y: @r(±20)%;
    --scale: @p(0.1, 0.2, 0.3, 0.5, 0.2, 0.8);
    --delta: @r(±10)vmin;

    animation: k 10s linear infinite both;

    @keyframes k {
      from { transform: rotate(var(--rotate)) translate(var(--translate-x), var(--translate-y)) scale(var(--scale)); }
      to { transform: rotate(var(--rotate)) translate(calc(var(--translate-x) + var(--delta)), calc(var(--translate-y) - @r(3, 6)vmin)) scale(var(--scale)); }
    }

    filter: @svg-filter(
      feTurbulence {
        type: fractalNoise;
        baseFrequency: @r(0.01, 0.1) @r(0.2, 1);
      }
      feDisplace.........完整代码请登录后点击上方下载按钮下载查看

网友评论0