Skip to content
    SeaCode
    Learning tracksCode ArenaWorkshops & EventsInstructors
    Log inSign up
    { }CSS

    Styling foundations

    • What is CSS?
    • Cascade and specificity
    • Selectors and element states
    • Colours and text

    Boxes and sizing

    • Padding, border and margin
    • Units and flexible sizing
    • Overflow and image fitting

    Layout and responsiveness

    • Flexbox
    • CSS Grid
    • Positioning and stacking
    • Responsive design
    • Container-based responsiveness

    Design values, direction and motion

    • CSS custom properties and functions
    • Logical properties for RTL and LTR
    • CSS transitions and transforms
    • Keyframes and bounded animation
    • Project: a product card
    CSS

    Design values, direction and motion · Lesson 16 of 17

    Keyframes and bounded animation

    Sequence motion without requiring hover.

    8 minutes2 games

    keyframes defines animation stages; animation attaches them to an element with duration and iteration count. Prefer brief motion to explain an event and avoid endless repetition. This example reveals a badge once.

    HTML
    <style>
      @keyframes arrive {from {opacity:0;transform:translateY(6px)} to {opacity:1;transform:translateY(0)}}
      .badge {display:inline-block;padding:12px;background:#dcfce7;animation:arrive 250ms ease-out both;}
      @media (prefers-reduced-motion:reduce) {.badge {animation:none;}}
    </style>
    <span class="badge">Lesson saved</span>

    from: initial state

    Interpolated values

    to: final state

    Important

    Reduced motion must preserve a clear final state. Avoid a base opacity:0 that relies on an animation which may be disabled.

    Interview question

    When should you use animation instead of transition?

    Quick question

    Which value disables animation?

    Exercise

    Disable the animation on .badge with animation:none.

    HTML
    <style>.badge{animation:pulse 1s infinite}</style><span class="badge">Saved</span>

    Learn more from

    • MDN: CSS referencedeveloper.mozilla.org
    • web.dev: animationsweb.dev

    Played 0 of 2 games

    Sign in to save your progress and earn XP.

    PreviousCSS transitions and transformsNextProject: a product card
    SeaCode

    Learn to code for real, online or at our branch in front of Cairo University, Giza.

    Learn

    • All courses
    • Interactive tutorials
    • Interview practice problems
    • Mock interview
    • Learning tracks
    • Code Arena
    • Workshops & Events
    • Knowledge library
    • Team projects

    Your account

    • Log in
    • Sign up
    • Learning plan
    • Certificates
    • Site map

    Contact us

    • WhatsApp
    • 010 9094 1104
    • In front of Cairo University, Giza

    © 2026 SeaCode. All rights reserved.