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
Recall & Review
beginner
What does the CSS transform property do?
The transform property changes the shape, size, or position of an element without affecting the document layout. It can move, rotate, scale, or skew elements visually.
Click to reveal answer
beginner
Name four common functions used with the transform property.
Common functions are: 1. translate(x, y) - moves the element. 2. rotate(angle) - rotates the element. 3. scale(x, y) - resizes the element. 4. skew(x-angle, y-angle) - slants the element.
Click to reveal answer
beginner
How does transform: translate(50px, 100px); affect an element?
It moves the element 50 pixels to the right and 100 pixels down from its original position, without changing the space it takes in the page layout.
Click to reveal answer
intermediate
What is the difference between transform: scale(2); and setting width and height to double?
Using scale(2) visually doubles the size but keeps the original layout space. Changing width and height actually changes the element's size and affects layout and surrounding elements.
Click to reveal answer
intermediate
Why is transform useful for animations and interactions?
transform is smooth and fast because it uses the GPU for rendering. It lets you move, rotate, or scale elements without reflowing the page, making animations look better and perform well.
Click to reveal answer
Which CSS property is used to move an element without changing its layout space?
Amargin
Btransform
Cposition
Dpadding
✗ Incorrect
The transform property moves elements visually without affecting the layout space.
What does transform: rotate(45deg); do to an element?
AMoves it 45 pixels right
BScales it to 45% size
CRotates it 45 degrees clockwise
DSkews it by 45 degrees
✗ Incorrect
The rotate(45deg) function turns the element 45 degrees clockwise.
Which transform function changes the size of an element?
Ascale()
Brotate()
Cskew()
Dtranslate()
✗ Incorrect
scale() changes the size of an element by stretching or shrinking it.
If you want to slant an element horizontally, which transform function do you use?
Atranslate()
Brotate()
Cscale()
Dskew()
✗ Incorrect
skew() slants the element along the X or Y axis.
Why is using transform better for animations than changing top or left?
AIt uses GPU for smoother animations
BIt changes the layout faster
CIt changes the element's size
DIt disables user interaction
✗ Incorrect
transform uses the GPU, making animations smoother and faster.
Explain how the CSS transform property can move, rotate, and scale an element. Give simple examples.
Think about how you can move or turn a picture without changing the space it takes on a wall.
You got /3 concepts.
Describe why transform is preferred for animations compared to changing position properties like top or left.
Imagine moving a toy on a table smoothly versus moving the whole table.
You got /3 concepts.
Practice
(1/5)
1. What does the CSS transform property do?
easy
A. It changes the position, size, or shape of an element visually.
B. It changes the background color of an element.
C. It adds a border around an element.
D. It hides the element from the page.
Solution
Step 1: Understand the purpose of transform
The transform property visually changes elements by moving, rotating, scaling, or skewing them.
Step 2: Compare with other CSS properties
Changing background color, borders, or visibility are done by other CSS properties, not transform.
Final Answer:
It changes the position, size, or shape of an element visually. -> Option A
Quick Check:
Transform = Visual change in shape/position [OK]
Hint: Remember transform moves or changes shape, not colors [OK]
Common Mistakes:
Confusing transform with color or visibility properties
Thinking transform changes content instead of appearance
Mixing transform with layout properties like margin or padding
2. Which of the following is the correct syntax to rotate an element by 45 degrees using transform?
easy
A. transform: rotate = 45deg;
B. transform: rotate45deg;
C. transform: rotate(45deg);
D. transform: rotate(45);
Solution
Step 1: Recall correct function syntax for rotate
The rotate function requires parentheses and a unit, like rotate(45deg).
Step 2: Check each option's syntax
transform: rotate(45deg); uses correct syntax with parentheses and unit. Options A, B, and D miss parentheses, equal sign, or units.
Final Answer:
transform: rotate(45deg); -> Option C
Quick Check:
Rotate needs parentheses and units [OK]
Hint: Use parentheses and units for transform functions [OK]
Confusing translateX with translateY (vertical move)
Thinking scale only changes width or height, not both
Ignoring the order of transform functions
4. Identify the error in this CSS code:
p {
transform: rotate 30deg;
}
medium
A. Missing parentheses around the angle value.
B. The unit 'deg' is not allowed with rotate.
C. The property name should be 'transform-rotate'.
D. Rotate cannot be used on paragraph elements.
Solution
Step 1: Check syntax for rotate function
The rotate function requires parentheses around the angle, like rotate(30deg).
Step 2: Review other options for correctness
Units like 'deg' are required. The property is correctly named transform. Rotate works on any element.
Final Answer:
Missing parentheses around the angle value. -> Option A
Quick Check:
Rotate needs parentheses around angle [OK]
Hint: Always use parentheses with transform functions [OK]
Common Mistakes:
Omitting parentheses in transform functions
Thinking 'deg' is invalid unit for rotate
Confusing property names like transform-rotate
5. You want to create a button that first scales up to 1.5 times its size and then rotates 90 degrees on hover. Which CSS transform property correctly combines these effects?
hard
A. transform: scale(1.5) rotate 90deg;
B. transform: scale(1.5) rotate(90deg);
C. transform: scale(1.5) + rotate(90deg);
D. transform: rotate(90deg) scale(1.5);
Solution
Step 1: Understand order of transform functions
Transforms are applied left to right. To scale first, then rotate, write scale(1.5) rotate(90deg).
Step 2: Check syntax for combining transforms
Transforms are combined by space-separated functions without operators or missing parentheses. transform: scale(1.5) rotate(90deg); is correct syntax.
Final Answer:
transform: scale(1.5) rotate(90deg); -> Option B
Quick Check:
Combine transforms with space, order matters [OK]
Hint: Write transforms space-separated in correct order [OK]