What does the animation-fill-mode property do in a CSS animation?
- It specifies the animation duration.
- It defines the timing function for the animation.
- It controls the behavior of the element before and after the animation.
- It sets the animation name.
The animation-fill-mode property is used to control the behavior of the animated element before and after the animation execution. It can have values like "none," "forwards," "backwards," and "both." "None" is the default value, which means the element doesn't maintain any styles before or after the animation. "Forwards" retains the styles after the animation ends, and "backwards" maintains the styles before the animation starts. "Both" keeps the styles both before and after the animation.
How do you include a mixin in your SCSS code?
- @apply myMixin();
- @include myMixin();
- @insert myMixin();
- @use myMixin();
To include a mixin in your SCSS code, you use the @include directive followed by the mixin name inside parentheses. For example, @include myMixin(); will include the styles defined in the myMixin mixin at that point in your stylesheet. You can also pass arguments to the mixin if it accepts them.
How can you make the text of an element bold using CSS?
- font-decoration: bold;
- font-weight: bold;
- text-decoration: bold;
- text-style: bold;
To make the text of an element bold in CSS, you should use the font-weight property and set it to the value bold. This increases the thickness of the characters, making them appear bold.
How can you target an element that is the only child of its parent using a pseudo-class?
- :first-child
- :last-child
- :nth-child(1)
- :only-child
To target an element that is the only child of its parent, you can use the :only-child pseudo-class. This selector is used when you want to apply styles or behavior to an element that is the only child within its parent container. For instance, you might want to style a single button in a list of buttons.
In terms of performance, why might you opt for the "woff2" font format over others?
- WOFF2 files are typically smaller in size
- WOFF2 fonts are easier to load asynchronously
- WOFF2 fonts are supported by more browsers
- WOFF2 provides higher quality and clearer text rendering
Opting for the "woff2" font format over others can improve web performance because WOFF2 files are generally smaller in size. Smaller files mean faster downloads and quicker web page rendering, resulting in a better user experience.
A font's loading performance can be improved by ________.
- compression
- inlining
- minifying
- preloading
A font's loading performance can be improved by "preloading." Preloading involves using the link element in the HTML to fetch and cache font files in advance, reducing the time it takes to load and render text with custom fonts.
What would be the primary reason to avoid excessive nesting in SASS or SCSS?
- Excessive nesting can lead to increased file size
- It helps with better code organization
- It improves the performance of stylesheets
- It is a recommended best practice
Excessive nesting in SASS or SCSS can lead to bloated and inefficient CSS files, which are larger in size. This negatively impacts loading times and page performance. It is advisable to avoid deep nesting to keep the stylesheet lean and maintainable.
What is the default value of the box-sizing property in CSS?
- border-box
- content-box
- margin-box
- padding-box
The default value of the 'box-sizing' property in CSS is 'content-box.' In this mode, the width and height of an element do not include padding or borders, only the content is considered. This can sometimes lead to unexpected layout behavior, which is why 'border-box' is often preferred.
When using Styled Components, how would you dynamically change the style of a component based on its props?
- Create separate component variants for each style and switch between them using conditional rendering.
- Styled Components do not support dynamic style changes based on props.
- Use the class prop to assign different CSS classes based on prop values.
- Use the style prop to pass in an inline CSS object and conditionally apply styles based on prop values.
In Styled Components, you can dynamically change the style of a component based on its props by using the style prop. You can pass in an inline CSS object and conditionally apply styles based on the values of the props. This allows for the creation of versatile and reusable components.
OOCSS primarily focuses on separating container and content, and promoting the reuse of ________.
- CSS rules
- HTML elements
- JavaScript functions
- Styles
Object-Oriented CSS (OOCSS) emphasizes separating the container and content in your styles and promoting the reuse of styles (i.e., CSS rules). This approach helps keep your CSS modular, making it easier to maintain and reducing redundancy in your code.
You are tasked with ensuring that all hyperlinks have no underlines but should be underlined when hovered over. How would you implement this using CSS?
- a { text-decoration: none; } a:hover { text-decoration: underline; }
- a { text-decoration: underline; }
- a { text-decoration: underline; } a:hover { text-decoration: none; }
- a:hover { text-decoration: underline; }
To ensure that hyperlinks have no underlines by default but are underlined when hovered over, you should use the CSS rule a { text-decoration: none; } to remove the underlines from all anchor elements and then use a:hover { text-decoration: underline; } to specify that underlines should appear when the link is hovered.
The ______ property in CSS lets you apply a delay before an animation starts.
- animation-delay
- animation-pause-delay
- animation-start-delay
- transition-delay
The property in CSS that allows you to apply a delay before an animation starts is the animation-delay. This property is used to create a pause before the animation begins, which is especially useful for sequencing animations.