Wednesday, 19 February 2025

MCQs for Class 20: CSS Transforms

  


MCQs for Class 20: CSS Transforms

1.   What is the purpose of the transform property in CSS?

o    (A) To change the background color of an element

o    (B) To align text

o    (C) To apply 2D and 3D transformations to elements

o    (D) To add spacing between elements
Answer: (C)
Explanation: The transform property applies 2D and 3D transformations, such as rotation, scaling, translation, and skewing, to an element.

2.   Which function rotates an element in CSS?

o    (A) translate()

o    (B) scale()

o    (C) rotate()

o    (D) skew()
Answer: (C)
Explanation: The rotate() function rotates an element around its origin.

3.   What unit is used in the rotate() function?

o    (A) px

o    (B) deg

o    (C) %

o    (D) rem
Answer: (B)
Explanation: The rotate() function uses degrees (deg) to specify the angle of rotation.

4.   Which of the following is a valid transform function?

o    (A) stretch()

o    (B) skew()

o    (C) translateX()

o    (D) Both (B) and (C)
Answer: (D)
Explanation: skew() and translateX() are valid transform functions.

5.   What does scale(1) do to an element?

o    (A) Doubles its size

o    (B) Reduces its size by half

o    (C) Maintains its original size

o    (D) None of the above
Answer: (C)
Explanation: A scale value of 1 means no change in size.


MCQs: Rotation and Translation

6.   How would you rotate an element by 45 degrees clockwise?

o    (A) rotate(45px)

o    (B) rotate(45deg)

o    (C) translate(45deg)

o    (D) skew(45deg)
Answer: (B)
Explanation: The rotate(45deg) function rotates the element by 45 degrees clockwise.

7.   Which function is used to move an element horizontally or vertically?

o    (A) translate()

o    (B) scale()

o    (C) skew()

o    (D) rotate()
Answer: (A)
Explanation: The translate() function shifts an element along the X and Y axes.

8.   What does translateX(50px) do?

o    (A) Moves the element 50px up

o    (B) Moves the element 50px to the right

o    (C) Moves the element 50px down

o    (D) Moves the element 50px to the left
Answer: (B)
Explanation: The translateX(50px) function moves the element 50px along the X-axis (to the right).

9.   How would you move an element 30px up and 40px left?

o    (A) translate(-30px, -40px)

o    (B) translate(-40px, -30px)

o    (C) translate(0, -30px)

o    (D) None of the above
Answer: (A)
Explanation: Negative values move the element in the opposite direction: left and up.

10.                     Which property ensures a smooth movement when applying transformations?

o    (A) animation

o    (B) transition

o    (C) display

o    (D) position
Answer: (B)
Explanation: The transition property adds smoothness to transformations.


MCQs: Scaling

11.                     What does scale(2) do?

o    (A) Doubles the size of the element

o    (B) Reduces the size by half

o    (C) Moves the element 2px

o    (D) Rotates the element
Answer: (A)
Explanation: The scale(2) function doubles the size of the element.

12.                     What happens if you use scale(0.5)?

o    (A) The element is halved in size

o    (B) The element doubles in size

o    (C) The element is rotated

o    (D) The element moves upward
Answer: (A)
Explanation: A scale value less than 1 shrinks the element.

13.                     Which function only scales an element along the X-axis?

o    (A) scale()

o    (B) scaleX()

o    (C) translateX()

o    (D) skewX()
Answer: (B)
Explanation: The scaleX() function scales the element along the X-axis.

14.                     How would you scale an element to 150% width but maintain its height?

o    (A) scaleX(1.5)

o    (B) scale(1.5, 1)

o    (C) scale(1, 1.5)

o    (D) Both (A) and (B)
Answer: (D)
Explanation: Both options work for scaling only the width.

15.                     What happens if scale(0) is applied?

o    (A) The element becomes invisible

o    (B) The element rotates

o    (C) The element becomes 0px in size

o    (D) Both (A) and (C)
Answer: (D)
Explanation: scale(0) shrinks the element to 0px, making it invisible.


MCQs: Skew and Combined Transforms

16.                     What does skew(20deg, 10deg) do?

o    (A) Tilts the element horizontally by 20 degrees and vertically by 10 degrees

o    (B) Rotates the element 30 degrees

o    (C) Moves the element diagonally

o    (D) Scales the element by 20% and 10%
Answer: (A)
Explanation: The skew() function tilts the element along both axes.

17.                     What does skewX(10deg) do?

o    (A) Tilts the element along the X-axis

o    (B) Tilts the element along the Y-axis

o    (C) Scales the element

o    (D) Moves the element along the X-axis
Answer: (A)
Explanation: skewX() tilts the element horizontally.

18.                     How would you combine scaling, rotation, and translation in one transform?

o    (A) Use transform: scale() rotate() translate()

o    (B) Use transform: scale(), rotate(), translate()

o    (C) Use transform: scale-rotate-translate()

o    (D) Combine them in separate transform properties
Answer: (A)
Explanation: Multiple transform functions are applied using a single transform property.


Remaining MCQs will follow the pattern above and include detailed questions on advanced 3D transforms, combining functions, and real-world applications of transform. Let me know if you'd like me to continue or add specific scenarios.

4o

You said:

yes

ChatGPT said:

ChatGPT

MCQs: Advanced Transform Concepts

19.                     What is the origin point of an element for transformations by default?

o    (A) Top-left corner

o    (B) Bottom-right corner

o    (C) Center of the element

o    (D) Top-right corner
Answer: (C)
Explanation: The default transformation origin is the center of the element unless specified using the transform-origin property.

20.                     Which property allows you to change the origin of a transformation?

o    (A) transform-origin

o    (B) transform-start

o    (C) origin-point

o    (D) transform-reference
Answer: (A)
Explanation: The transform-origin property sets the pivot point for transformations.

21.                     How do you create a 3D rotation effect in CSS?

o    (A) Use rotate()

o    (B) Use rotateX() or rotateY()

o    (C) Use scale() and translate() together

o    (D) Use skew()
Answer: (B)
Explanation: The rotateX() and rotateY() functions enable 3D rotation effects.

22.                     What does translate3d(50px, 20px, 10px) do?

o    (A) Moves the element in 3D space

o    (B) Rotates the element in 3D space

o    (C) Scales the element in 3D space

o    (D) Skews the element
Answer: (A)
Explanation: The translate3d() function moves the element along the X, Y, and Z axes.

23.                     Which function scales an element in 3D space?

o    (A) scale()

o    (B) scale3d()

o    (C) transform()

o    (D) skew3d()
Answer: (B)
Explanation: The scale3d() function allows scaling along the X, Y, and Z axes.


MCQs: Real-world Scenarios

24.                     Which of the following creates a flipping card animation?

o    (A) rotateY(180deg)

o    (B) scale(0.5)

o    (C) skew(45deg)

o    (D) translateY(50px)
Answer: (A)
Explanation: The rotateY(180deg) function flips the element around the Y-axis, creating a card flip effect.

25.                     How would you enlarge an element on hover using CSS transforms?

o    (A) hover { transform: scale(1.5); }

o    (B) hover { transform: rotate(1.5); }

o    (C) hover { transform: translate(1.5); }

o    (D) hover { transform: skew(1.5); }
Answer: (A)
Explanation: The scale(1.5) function enlarges the element by 1.5 times its original size on hover.

26.                     How would you move an element diagonally in CSS?

o    (A) Use translateX()

o    (B) Use translateY()

o    (C) Use translate() with both X and Y values

o    (D) Use skew()
Answer: (C)
Explanation: The translate(x, y) function moves the element diagonally by specifying both X and Y values.

27.                     Which property creates a 3D perspective effect?

o    (A) perspective

o    (B) transform-origin

o    (C) transform

o    (D) rotateZ()
Answer: (A)
Explanation: The perspective property creates depth, making 3D transformations more realistic.

28.                     What does rotateZ(90deg) do?

o    (A) Rotates the element along the Z-axis

o    (B) Rotates the element along the X-axis

o    (C) Rotates the element along the Y-axis

o    (D) Moves the element along the Z-axis
Answer: (A)
Explanation: The rotateZ() function rotates the element around the Z-axis (in the 2D plane).


MCQs: Combining Transforms

29.                     How would you rotate and scale an element simultaneously?

o    (A) Use transform: rotate() scale()

o    (B) Use transform: rotate-scale()

o    (C) Use separate rotate and scale properties

o    (D) Use transition
Answer: (A)
Explanation: Multiple transform functions can be combined within a single transform property.

30.                     What happens if multiple transform functions are applied together?

o    (A) They are applied sequentially from left to right

o    (B) They overwrite each other

o    (C) Only the last function is applied

o    (D) They are applied simultaneously in random order
Answer: (A)
Explanation: Transform functions are applied sequentially from left to right, affecting the final result.

31.                     How would you create a 2D rotation and a 3D translation?

o    (A) Use transform: rotate() translate3d()

o    (B) Use transform: translate() scale()

o    (C) Use transform-origin

o    (D) None of the above
Answer: (A)
Explanation: You can combine rotate() and translate3d() in a single transform property for mixed 2D and 3D effects.


MCQs: Lab Exercises and Practical Application

32.                     Which of the following is required to apply animation to transformed elements?

o    (A) transform

o    (B) transition

o    (C) animation

o    (D) Both (B) and (C)
Answer: (D)
Explanation: Both transition and animation can animate transformed elements, but they serve different purposes.

33.                     What does transform: none do?

o    (A) Resets all applied transformations

o    (B) Hides the element

o    (C) Changes the element to its default size

o    (D) Removes the element
Answer: (A)
Explanation: The transform: none property removes any previously applied transformations.


Let me know if you'd like the remaining questions to be even more advanced or explore specific scenarios like interactive UI design!

4o

You said:

rest

ChatGPT said:

ChatGPT

Here are the remaining MCQs:


MCQs: Transform Functions and Effects

34.                     What does scaleX(1.5) do to an element?

o    (A) Scales the element in the X direction by 1.5 times its original size

o    (B) Scales the element in the Y direction by 1.5 times its original size

o    (C) Rotates the element by 1.5 degrees

o    (D) Moves the element in the X direction by 1.5 units
Answer: (A)
Explanation: The scaleX() function scales the element in the X direction. A value greater than 1 increases its width.

35.                     How do you move an element to the right by 50px and upwards by 100px using translate()?

o    (A) transform: translate(50px, -100px)

o    (B) transform: translate(50px, 100px)

o    (C) transform: translateX(50px) translateY(100px)

o    (D) transform: translateX(50px) translateY(-100px)
Answer: (D)
Explanation: To move the element to the right, use translateX(50px), and to move it upwards, use translateY(-100px).

36.                     How do you rotate an element around its X-axis in 3D space?

o    (A) transform: rotateX(90deg)

o    (B) transform: rotate3d(1, 0, 0, 90deg)

o    (C) transform: rotate(90deg)

o    (D) transform: rotateY(90deg)
Answer: (A)
Explanation: The rotateX() function rotates an element around its X-axis in 3D space.

37.                     Which property can you use to prevent a transformation from affecting the layout of an element?

o    (A) position

o    (B) transform-style

o    (C) perspective

o    (D) backface-visibility
Answer: (B)
Explanation: The transform-style property specifies how nested elements are treated in 3D space, particularly in terms of layout.

38.                     What does skew(45deg) do to an element?

o    (A) Applies a 45-degree tilt along the X-axis

o    (B) Rotates the element by 45 degrees

o    (C) Distorts the element's shape by skewing along the X and Y axes

o    (D) Moves the element by 45 pixels
Answer: (C)
Explanation: The skew() function distorts an element's shape by slanting it along both axes.

39.                     How do you apply a skew transformation along both the X and Y axes?

o    (A) transform: skew(30deg, 30deg)

o    (B) transform: skewX(30deg) skewY(30deg)

o    (C) transform: skew(30deg)

o    (D) transform: rotate(30deg)
Answer: (A)
Explanation: The skew() function accepts two parameters: one for the X-axis and one for the Y-axis.

40.                     Which property is used to apply perspective to 3D transforms?

o    (A) transform-origin

o    (B) perspective

o    (C) transform

o    (D) perspective-origin
Answer: (B)
Explanation: The perspective property determines the distance from the viewer, creating a 3D effect.

41.                     What does rotate3d(1, 1, 0, 45deg) do?

o    (A) Rotates an element 45 degrees around both the X and Y axes

o    (B) Rotates an element 45 degrees around the Z-axis

o    (C) Rotates an element 45 degrees along the X-axis

o    (D) Rotates an element 45 degrees along the Y-axis
Answer: (A)
Explanation: The rotate3d() function rotates an element around the X, Y, and Z axes. The parameters specify the axis of rotation and the angle.

42.                     Which of the following functions is used to create a 3D scaling effect?

o    (A) scale()

o    (B) scale3d()

o    (C) scaleX()

o    (D) scaleY()
Answer: (B)
Explanation: The scale3d() function scales the element along the X, Y, and Z axes in 3D space.

43.                     What does transform: translate(-50%, -50%) do to an element?

o    (A) Moves the element up and left by 50% of its width and height

o    (B) Moves the element down and right by 50% of its width and height

o    (C) Moves the element diagonally

o    (D) No effect
Answer: (A)
Explanation: The translate(-50%, -50%) function shifts the element to the top-left by 50% of its width and height, typically used to center it.

44.                     Which function can be used to animate the rotation of an element?

o    (A) rotate()

o    (B) rotateZ()

o    (C) rotateX()

o    (D) All of the above
Answer: (D)
Explanation: Any of the rotate(), rotateX(), or rotateZ() functions can be used to rotate an element.

45.                     What is the main purpose of the transform-style property in 3D transformations?

o    (A) To set the pivot point for transformations

o    (B) To determine if nested elements should be rendered in 3D

o    (C) To set the timing function for animations

o    (D) To scale the element in 3D
Answer: (B)
Explanation: The transform-style property specifies how nested elements are rendered in 3D space.

46.                     What is the default value of transform-style property?

o    (A) flat

o    (B) 3d

o    (C) perspective

o    (D) none
Answer: (A)
Explanation: The default value of transform-style is flat, meaning that child elements do not maintain their 3D space unless specified otherwise.

47.                     Which of these transform functions would you use to make an object appear stretched vertically?

o    (A) scaleX()

o    (B) scaleY()

o    (C) translateY()

o    (D) rotateY()
Answer: (B)
Explanation: The scaleY() function allows you to stretch or compress an element vertically.

48.                     How do you animate an element with a smooth transition between a scale and rotate transformation?

o    (A) transition: transform 1s ease-in-out;

o    (B) transition: rotate 1s ease-in-out;

o    (C) transition: scale 1s ease-in-out;

o    (D) transition: all 1s ease-in-out;
Answer: (A)
Explanation: The transition: transform property will allow for a smooth transition when applying scale() or rotate() transformations.

49.                     Which transformation function is best for creating an object that slides diagonally across the page?

o    (A) translateX()

o    (B) translateY()

o    (C) translate()

o    (D) rotate()
Answer: (C)
Explanation: The translate() function allows you to move an object diagonally when both X and Y values are used.

50.                     Which property can help you control the speed of transformations over time?

o    (A) transition-timing-function

o    (B) transform-duration

o    (C) transform-delay

o    (D) transition-duration
Answer: (D)
Explanation: The transition-duration property controls how long the transformation takes to complete.



No comments:

Post a Comment

Search This Blog

Powered by Blogger.