Animating properties like opacity and transform is considered more performant because they don't trigger ________ in most browsers.

  • redraws
  • relayouts
  • repaints
  • rerenders
When certain properties like opacity and transform are animated, they are considered more performant because they typically don't trigger relayouts or "reflows" in most browsers. Relayouts are costly in terms of performance and can significantly slow down animations.

What is the role of the grid-gap property in a grid layout?

  • It defines the number of columns in the grid.
  • It determines the background color of the grid.
  • It sets the width of the entire grid.
  • It specifies the gap between grid items.
The grid-gap property is used to specify the gap or spacing between grid items (rows and columns) in a grid layout. It helps in controlling the spacing and alignment of items within the grid.

You are tasked with creating a list where every even item has a gray background. Which CSS selector would help you accomplish this?

  • :even
  • :nth-child(even)
  • :nth-child(odd)
  • :odd
To select every even item in a list, you should use the :nth-child(even) selector. This will apply the styling to the elements with even indices in the list, which will give them a gray background in this scenario.

You are developing a website where you want to use modern CSS features not yet supported in all browsers. How can you ensure compatibility without manually writing fallbacks?

  • Use a CSS preprocessor like SASS
  • Employ a PostCSS plugin
  • Write conditional JavaScript code
  • Ignore unsupported features
To ensure compatibility with modern CSS features, you can use a PostCSS plugin like "autoprefixer" that automatically generates fallback code for unsupported features, allowing you to write modern CSS with confidence. This minimizes the need for manual fallbacks.

SCSS functions can be used to perform ________ before the CSS is compiled.

  • Code execution
  • Conditional statements
  • Looping operations
  • Mathematical calculations
SCSS functions can be used to perform mathematical calculations, such as addition, subtraction, and multiplication, before the CSS is compiled. This allows you to generate dynamic and responsive styles based on input values.

The CSS function ______ allows you to perform arithmetic calculations directly within your stylesheets.

  • arithmetic()
  • calc()
  • compute()
  • math()
The correct CSS function that enables you to perform arithmetic calculations directly within your stylesheets is calc(). This function is particularly useful for dynamically adjusting styles based on calculations, making it a powerful tool for responsive design and layout adjustments.

When using CSS to mask an element, the area defined by the mask image that is ________ will be visible.

  • hidden
  • revealed
  • transparent
  • visible
When using CSS to mask an element, the area defined by the mask image that is transparent will be visible. A mask hides or reveals parts of an element based on the transparency of the mask image. Areas in the mask image that are transparent reveal the underlying content.

Which positioning value makes an element positioned relative to its original position?

  • absolute
  • fixed
  • relative
  • static
The positioning value that makes an element positioned relative to its original position is relative. When you set an element's position to relative, you can use properties like top, right, bottom, and left to move it relative to where it would have been in the normal document flow. This can be useful for fine-tuning element placement.

How can you ensure smoother animations when translating an element's position?

  • transform: translate(0);
  • transition: all 0.5s ease;
  • will-change: transform;
  • z-index: 10;
To ensure smoother animations when translating an element's position, you can use the will-change property with the transform value. This hints to the browser that the element's transform property will change, allowing the browser to optimize rendering. It's a good practice to use will-change for performance optimization in animations.

How can you ensure that a CSS transition applies only when a specific property changes?

  • By using the transition property without specifying any properties.
  • By using the all value for the transition-property property.
  • By creating a separate CSS class for each property you want to transition.
  • By defining multiple transition rules for each property.
To ensure that a CSS transition applies only when a specific property changes, you can use the transition-property property and set it to "all." This means the transition will be applied to all properties that change. If you want to target specific properties, you can list them individually in the transition-property property. Using "all" is a convenient way to apply transitions to all changing properties.

The em unit in CSS is relative to the ________.

  • Body background color
  • Font-size of the parent element
  • Screen width
  • Width of the border
The em unit in CSS is relative to the font-size of the parent element. It's a relative unit, making it valuable for creating scalable and responsive designs. When you set an element's font-size in ems, it's relative to its parent's font-size.

What does the CSS property "line-height" primarily affect?

  • Background color
  • Font color
  • Spacing between lines of text
  • Text size
The CSS property "line-height" primarily affects the spacing between lines of text within an element. It determines the vertical distance between the baselines of two consecutive lines of text. Adjusting the line-height can impact the readability and aesthetics of text on a webpage.