topskill.dev
CoursesTracks
0
All courses/CSSKite festival signal
Project - Animation and Interaction
1 / 3
← CSS
○CSS Rule Style an Exhibit Card○Write Your First CSS Rule○CSS Selectors Target Exhibit Details○Target Exhibit Details○Apply CSS Three Sources○Apply CSS Three Ways○Specificity Resolve a Style Conflict○Resolve Specificity○Inheritance and the cascade✦Module Quiz
○Color Palette○Color Palette○Background Layer○Background Layer○Type Rhythm○Type Rhythm○Borders and Shadows○Borders and Shadows✦Module Quiz
○Box Model Seed Packet Card○Space a Seed Packet○Display Swap Table Labels○Arrange Swap Table Labels○Positioning Pickup Pin○Pin the Pickup Location○Sizing and Overflow○Size a Seed-Swap Notice○Sticky scroll headings✦Module Quiz
○Advanced Selectors Book Cart Sign○Target a Book Cart Sign○Pseudo-Classes Night Cart States○Style Night Cart States○Pseudo-Elements○Add a Book-Quote Mark✦Module Quiz
○Lantern Market navigation○Lantern Market navigation✦Module Quiz
○Community garden request card○Community garden request card✦Module Quiz
○Flex Direction○Flex Direction○Main-Axis Spacing○Main-Axis Spacing○Cross-Axis Alignment○Cross-Axis Alignment○Wrapping and Flex Items○Wrapping and Flex Items○Flexbox Navigation○Flexbox Navigation✦Module Quiz
○Grid Tracks○Grid Tracks○Grid Gaps○Grid Gaps○Grid Placement○Grid Placement○Responsive Grid○Responsive Grid✦Module Quiz
○River radio schedule○Harbor radio schedule✦Module Quiz
○Field note color system○Field note color system○Transforms○Rotate a Field Note○Resilient styles✦Module Quiz
●Kite festival signal○Garden festival signal✦Module Quiz
○Garden forecast○Harbor forecast○Fluid sizing○Fluid weather bulletin○Images that fit✦Module Quiz
○Seed inventory table○Tool checkout table✦Module Quiz
○Community maker profile○Maker profile sheet✦Module Quiz

Kite festival signal

Make the festival kite drift upward and back. Unlike a transition, which waits for a property to change, a keyframe animation can begin as soon as the page loads. The button is only a styled placeholder; it does not reserve a pass.

Read the motion rules

@keyframes drift names a sequence. from is its starting state and to is its ending state. Here transform: translateY(0) starts in the original position, while translateY(-14px) paints the kite 14 pixels higher. A negative Y value moves upward; this does not rearrange the surrounding layout.

The .kite rule attaches the sequence with animation: drift 2s ease-in-out 2 alternate:

  • drift names the keyframes.
  • 2s gives each trip a duration of two seconds.
  • ease-in-out slows the beginning and end of each trip.
  • 2 runs two iterations: one upward trip and one returning trip.
  • alternate reverses every other trip, bringing the kite back down.

The button uses transition: transform 160ms ease. This smooths a transform change over 160 milliseconds. Hovering or keyboard-focusing the button applies translateY(-2px); leaving that state returns it to its original position.

The two trips finish after four seconds. For longer automatic motion alongside other content, give visitors a persistent pause/stop control; reduced-motion support alone is not that control. The infinite keyword exists, but an endless decorative loop is not the default here.

Respect less-motion settings

@media (prefers-reduced-motion: reduce) applies when the visitor requests less motion. Unlike a width query, it checks a preference. Inside it, animation: none stops the kite, and transition: none removes the button's interpolation. We also reset the highlighted button's transform to none: disabling a transition alone would still leave an instant position change. The focus outline remains visible.

Try the demo

Change the ending keyframe from -14px to -5px in style.css, Run Preview, and watch the shorter travel. Restore it. Hover the button, then use Tab to inspect its keyboard highlight. Enable reduced motion in your system or browser's rendering tools and rerun: the kite and button should stay still. Restore your preferred setting afterward.

Hint 1
1 / 2
HINT 1

Keep the stylesheet linked from the document head.

HINT 2

Change one declaration at a time, then use Run Preview to inspect the result.

Files
  • ⋄index.html
  • ⋄style.css
Loading editor…