Jump into concepts and practice - no test required
or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Transform Elements with Tailwind CSS
📖 Scenario: You are creating a simple webpage with a colored square. You want to apply different transformations to this square using Tailwind CSS classes.
🎯 Goal: Build a webpage with a square <div> that you will scale, rotate, and translate step-by-step using Tailwind CSS transform classes.
📋 What You'll Learn
Create a square <div> with a background color and fixed size
Add a Tailwind CSS class to scale the square to 125%
Add a Tailwind CSS class to rotate the square by 45 degrees
Add a Tailwind CSS class to translate the square 10 units right and 5 units down
💡 Why This Matters
🌍 Real World
Transformations like scaling, rotating, and translating elements are common in web design to create interactive and visually appealing interfaces.
💼 Career
Knowing how to use CSS transforms with utility-first frameworks like Tailwind CSS is valuable for frontend developers to quickly style and animate UI components.
Progress0 / 4 steps
1
Create the square <div>
Create a <div> with the classes bg-blue-500, w-24, and h-24 inside the <main> element.
Tailwind
Hint
Use bg-blue-500 for background color and w-24 h-24 for width and height.
2
Scale the square to 125%
Add the Tailwind CSS class scale-125 to the existing <div> to scale it to 125%.
Tailwind
Hint
Use the scale-125 class to enlarge the element by 25%.
3
Rotate the square by 45 degrees
Add the Tailwind CSS class rotate-45 to the <div> to rotate it 45 degrees clockwise.
Tailwind
Hint
Use the rotate-45 class to rotate the element 45 degrees clockwise.
4
Translate the square 10 units right and 5 units down
Add the Tailwind CSS classes translate-x-10 and translate-y-5 to the <div> to move it 2.5rem right and 1.25rem down.
Tailwind
Hint
Use translate-x-10 to move right and translate-y-5 to move down.
Practice
(1/5)
1. What does the Tailwind class scale-110 do to an element?
easy
A. It makes the element 110% transparent.
B. It rotates the element by 110 degrees.
C. It makes the element 10% larger than its original size.
D. It moves the element 110 pixels to the right.
Solution
Step 1: Understand the scale utility
The scale-110 class in Tailwind increases the size of the element by 110%, which means 10% larger than normal.
Step 2: Differentiate from other transforms
Rotation and translation use different classes like rotate- and translate-. Transparency uses opacity classes, not scale.
Final Answer:
It makes the element 10% larger than its original size. -> Option C
Quick Check:
scale-110 means 110% size = 10% larger [OK]
Hint: Scale classes change size by percentage, not position or rotation [OK]
Common Mistakes:
Confusing scale with rotate or translate
Thinking scale changes transparency
Assuming scale-110 means 110 pixels
2. Which Tailwind class correctly rotates an element by 45 degrees clockwise?
easy
A. rotate-45
B. scale-45
C. translate-45
D. rotate-90
Solution
Step 1: Identify rotation classes
Tailwind uses rotate- followed by degrees to rotate elements. rotate-45 means rotate 45 degrees clockwise.
Step 2: Exclude other transform types
scale- changes size, translate- moves position, and rotate-90 rotates 90 degrees, not 45.
Final Answer:
rotate-45 -> Option A
Quick Check:
rotate-45 means 45 degrees rotation [OK]
Hint: Rotate classes use degrees, scale and translate do not rotate [OK]
Common Mistakes:
Using scale or translate classes for rotation
Choosing wrong rotation degree
Confusing clockwise and counterclockwise directions
3. What visual effect will this Tailwind code produce?
A. A blue box normal size, no rotation, moved right by 4rem
B. A blue box twice its size, rotated 90 degrees, moved left by 4rem
C. A blue box half its size, rotated 45 degrees, moved right by 4rem
D. A blue box half its size, rotated 90 degrees, moved right by 1rem
Solution
Step 1: Decode each transform class
translate-x-4 moves the element right by 1rem (4 * 0.25rem), rotate-90 rotates it 90 degrees clockwise, and scale-50 scales it to 50% size (half).
Step 2: Combine visual effects
The box will appear smaller (half size), rotated on its center by 90 degrees, and shifted right by 1rem. The background and size classes set color and base size.
Final Answer:
A blue box half its size, rotated 90 degrees, moved right by 1rem -> Option D