Bounce animation helps grab attention by making elements move up and down smoothly.
Bounce animation (attention) in Tailwind
<element class="animate-bounce">Content</element>The animate-bounce class applies a smooth up-and-down movement.
You can add this class to any HTML element like buttons, images, or text.
<button class="animate-bounce bg-blue-500 text-white px-4 py-2 rounded">Click me</button><div class="animate-bounce text-red-600 font-bold">New!</div><img src="icon.png" alt="Icon" class="animate-bounce w-12 h-12" />
This page shows a green button, a purple text, and a star icon all bouncing to attract attention. The button has keyboard focus styles for accessibility. The text uses role="alert" to indicate importance.
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" /> <meta name="viewport" content="width=device-width, initial-scale=1" /> <title>Bounce Animation Example</title> <script src="https://cdn.tailwindcss.com"></script> </head> <body class="flex flex-col items-center justify-center min-h-screen bg-gray-100 gap-6"> <button class="animate-bounce bg-green-600 text-white px-6 py-3 rounded-lg shadow-lg focus:outline-none focus:ring-4 focus:ring-green-300" aria-label="Bounce attention button">Bounce Button</button> <p class="animate-bounce text-xl font-semibold text-purple-700" role="alert">Attention! This text bounces.</p> <img src="https://cdn-icons-png.flaticon.com/512/1828/1828817.png" alt="Bouncing star icon" class="animate-bounce w-16 h-16" /> </body> </html>
The bounce animation repeats infinitely by default.
Use aria-label and role attributes to keep animations accessible.
Too much bouncing can be distracting; use it sparingly for best effect.
Bounce animation makes elements move up and down smoothly to catch attention.
Use the animate-bounce class on buttons, text, or images.
Keep animations accessible and use them thoughtfully.
Practice
animate-bounce do to an element?Solution
Step 1: Understand the purpose of
Theanimate-bounceanimate-bounceclass in Tailwind CSS applies a smooth up-and-down movement to the element.Step 2: Compare with other animation effects
Other options describe color change, rotation, or fading, which are not whatanimate-bouncedoes.Final Answer:
Makes the element move up and down repeatedly to attract attention -> Option CQuick Check:
Bounce animation = up and down movement [OK]
- Confusing bounce with color or rotation animations
- Thinking it fades the element
- Assuming it moves side to side
Solution
Step 1: Recall the exact Tailwind class for bounce animation
The correct class isanimate-bounce, not variations likebounce-animationorbounce.Step 2: Check the button element syntax
Click me usesclass="animate-bounce"correctly on the button element.Final Answer:
<button class="animate-bounce">Click me</button> -> Option BQuick Check:
Useanimate-bounceclass exactly [OK]
- Adding extra words to the class name
- Using incomplete or incorrect class names
- Forgetting to add the class attribute
<button class="animate-bounce bg-blue-500 text-white p-4 rounded">Bounce</button>
Solution
Step 1: Analyze the classes applied
The button hasanimate-bouncefor bounce animation,bg-blue-500for blue background,text-whitefor white text,p-4for padding, androundedfor rounded corners.Step 2: Predict the visual output
The button will appear blue with white text and will bounce up and down smoothly.Final Answer:
A blue button that smoothly moves up and down repeatedly -> Option AQuick Check:
animate-bounce = smooth up/down movement [OK]
- Ignoring the animate-bounce class effect
- Confusing bounce with fade or spin
- Assuming no animation without checking classes
<p class="bounce">Hello</p> does not animate. What is the problem?Solution
Step 1: Check the class name used
The classbounceis not a valid Tailwind animation class. The correct class isanimate-bounce.Step 2: Confirm element animatability
Paragraph tags can be animated with Tailwind classes, so the tag is not the issue.Final Answer:
The class name should beanimate-bounce, notbounce-> Option DQuick Check:
Use exact classanimate-bounce[OK]
- Using incomplete class names like bounce
- Thinking only buttons animate
- Assuming tag type blocks animation
Solution
Step 1: Understand Tailwind hover syntax
Tailwind useshover:prefix to apply styles on hover. To stop animation on hover, usehover:animate-none.Step 2: Check each option's correctness
<div class="animate-bounce hover:animate-none">🔔</div>correctly usesanimate-bounceand stops animation on hover withhover:animate-none. Other options use invalid classes or do not stop animation.Final Answer:
<div class="animate-bounce hover:animate-none">🔔</div> -> Option AQuick Check:
Use hover:animate-none to stop bounce on hover [OK]
- Using invalid class names like bounce or stop-bounce
- Not using hover prefix correctly
- Assuming hover disables animation without class
Ready to prove it?
Pass the test and this pattern moves unknown
