VDone Demo VDone Demo
Home
  • Articles

    • JavaScript
  • Study Notes

    • JavaScript Tutorial
    • Professional JavaScript
    • ES6 Tutorial
    • Vue
    • React
    • TypeScript: Build Axios from Scratch
    • Git
    • TypeScript
    • JS Design Patterns
  • HTML
  • CSS
  • Technical Docs
  • GitHub Tips
  • Node.js
  • Blog Setup
  • Learning
  • Interviews
  • Miscellaneous
  • Practical Tips
  • Friends
About
Bookmarks
  • Categories
  • Tags
  • Archives
GitHub (opens new window)

Nikolay Tuzov

Backend Developer
Home
  • Articles

    • JavaScript
  • Study Notes

    • JavaScript Tutorial
    • Professional JavaScript
    • ES6 Tutorial
    • Vue
    • React
    • TypeScript: Build Axios from Scratch
    • Git
    • TypeScript
    • JS Design Patterns
  • HTML
  • CSS
  • Technical Docs
  • GitHub Tips
  • Node.js
  • Blog Setup
  • Learning
  • Interviews
  • Miscellaneous
  • Practical Tips
  • Friends
About
Bookmarks
  • Categories
  • Tags
  • Archives
GitHub (opens new window)
  • HTML

  • CSS

    • CSS Tutorials and Tips Collection
    • Flex Layout Syntax
    • Flex Layout Example - Basics
    • Flex Layout Example - Dice
    • Flex Layout Example - Holy Grail Layout
    • Flex Layout Example - Grid Layout
    • Flex Layout Example - Input Layout
    • CSS3 Transition
    • CSS3 Animation
      • Layout Tip - Auto-Expand Element Height Before Images Load
      • Text Overflow Ellipsis for Single and Multiple Lines
      • Understanding the Box Model Through the box-sizing Property
      • Horizontal and Vertical Centering Methods - Examples
      • How to Automatically Respond to CSS Dark Mode Based on System Theme
      • CSS Trick - Custom Hover Tooltips with :hover and attr()
      • CSS Functions Summary
      • Adding a Scrollbar to a Table's tbody with CSS
      • Animations in Grid Layout
    • 页面
    • CSS
    xugaoyi
    2019-12-25
    Contents

    CSS3 Animation

    # CSS3 Animation

    You can use F12 developer tools to inspect elements and styles, or open CodePen to edit the code online.

    <html>
      <div class="animationBox">
        <div class="rotate">Rotation 1</div>
        <div class="play">
          <div class="img">Rotation 2</div>
          <span><p class="p2"></p></span>
          <span><p></p></span>
          <span><p></p></span>
          <span><p class="p2"></p></span>
        </div>
        <div class="elasticity">Elastic Anim</div>
        <div class="elasticity2">Curve Elastic</div>
      </div>
    </html>
    
    <style>
      .animationBox{overflow: hidden;}
      .animationBox>div{
        width: 100px;height: 100px;background: #eee;border-radius: 50%;text-align: center;line-height: 100px;margin: 30px;float:left;
      }
      .rotate{
        animation: rotate 5s linear infinite
      }
      .rotate:hover{ animation-play-state: paused}
      @keyframes rotate {
        0%{transform: rotate(0);}
      100%{transform: rotate(360deg);}
      }
      .animationBox>.play {
        position: relative;
        margin: 50px 30px;
        background:none;
      }
      .play .img{
        position: absolute;
        top: 0;
        left:0;
        z-index: 1;
        width: 100px;height: 100px; background: #eee;
        border-radius: 50%;
    
        animation: rotate 5s linear infinite
      }
      .play span {
        position: absolute;
        top: 1px;
        left:1px;
        z-index: 0;
        display: block;
        width: 96px;
        height: 96px;
        border: 1px solid #999;
        border-radius: 50%;
      }
      .play span p{display: block;width: 4px;height: 4px;background: #000;margin: -2px 0 0 50%;border-radius: 50%;opacity: 0.5;}
      .play span .p2{margin: 50% 0 0 -2px;}
      .play span{
        animation: wave 5s linear infinite
      }
      .play>span:nth-child(3){
        /* Delay time */
        animation-delay:1s; 
      }
      .play>span:nth-child(4){
        animation-delay:2.2s;
      }
      .play>span:nth-child(5){
        animation-delay:3.8s;
      }
      
      @keyframes wave {
        0%
        {
          transform:scale(1) rotate(360deg);
          opacity: 0.8;
        }
      100%
        {
          transform:scale(1.8) rotate(0deg);
          opacity: 0;
        }
      }
    
    
      .elasticity{
        /* Parameters:
          animation-name duration bezier-curve delay iteration-count(n|infinite) direction(whether to play in reverse)
        */
        animation: elasticity 1s linear 2s infinite
      }
      
      @keyframes elasticity{
        0%{
          transform: scale(0);
        }
        60%{
          transform: scale(1.1);
        }
        90%{
          transform: scale(1);
        }
      }
      
    
      .elasticity2{
        /**
        Bezier curve cubic-bezier(x1,y1,x2,y2)
    
        By adjusting the Bezier curve, you can create various animation effects, such as bounce effects.
        X-axis range is 0~1; the Y-axis range is not strictly defined, but should not be too large.
        Linear: cubic-bezier(0,0,1,1)
    
        Bezier curve online tool: https://cubic-bezier.com/#.17,.67,.83,.67
          */
        animation: elasticity2 1s cubic-bezier(.39,.62,.74,1.39) 2s infinite
      }
      @keyframes elasticity2{
        0%{
          transform: scale(0);
        }
        90%{
          transform: scale(1);
        }
      }
    </style>
    
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125

    # Bezier Curve cubic-bezier(x1,y1,x2,y2)

    By adjusting the Bezier curve, you can create various animation effects, such as bounce effects. The X-axis range is 0~1; the Y-axis range is not strictly defined, but should not be too large. For example: linear, i.e., cubic-bezier(0,0,1,1)

    Bezier curve online tool: https://cubic-bezier.com/#.17,.67,.83,.67 (opens new window)

    Reference: https://www.w3school.com.cn/css3/index.asp (opens new window)

    Edit (opens new window)
    Last Updated: 2026/03/21, 12:14:36
    CSS3 Transition
    Layout Tip - Auto-Expand Element Height Before Images Load

    ← CSS3 Transition Layout Tip - Auto-Expand Element Height Before Images Load→

    Recent Updates
    01
    How I Discovered Disposable Email — A True Story
    06-12
    02
    Animations in Grid Layout
    09-15
    03
    Renaming a Git Branch
    08-11
    More Articles >
    Theme by VDone | Copyright © 2026-2026 Nikolay Tuzov | MIT License | Telegram
    • Auto
    • Light Mode
    • Dark Mode
    • Reading Mode