Bird
Raised Fist0
SASSmarkup~20 mins

Vendor prefix mixin patterns in SASS - Practice Problems & Coding Challenges

Choose your learning style10 modes available
Challenge - 5 Problems
🎖️
Vendor Prefix Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
📝 Syntax
intermediate
2:00remaining
What is the output CSS of this Sass mixin usage?
Given the following Sass mixin and usage, what CSS will be generated?
@mixin transform($value) {
  -webkit-transform: $value;
  -moz-transform: $value;
  transform: $value;
}

.box {
  @include transform(rotate(45deg));
}
SASS
@mixin transform($value) {
  -webkit-transform: $value;
  -moz-transform: $value;
  transform: $value;
}

.box {
  @include transform(rotate(45deg));
}
A
.box {
  -moz-transform: rotate(45deg);
  transform: rotate(45deg);
}
B
.box {
  transform: rotate(45deg);
  -webkit-transform: rotate(45deg);
  -moz-transform: rotate(45deg);
}
C
.box {
  -webkit-transform: rotate(45deg);
  transform: rotate(45deg);
}
D
.box {
  -webkit-transform: rotate(45deg);
  -moz-transform: rotate(45deg);
  transform: rotate(45deg);
}
Attempts:
2 left
💡 Hint
Remember the order of properties in the mixin matches the output order.
🧠 Conceptual
intermediate
1:30remaining
Why use vendor prefix mixins in Sass?
Which of the following best explains why developers use vendor prefix mixins in Sass?
ATo write CSS properties once and automatically add all needed vendor prefixes for browser support.
BTo avoid writing any CSS properties and rely on browsers to add prefixes automatically.
CTo make CSS files larger by repeating properties with prefixes manually.
DTo prevent browsers from applying any vendor-specific styles.
Attempts:
2 left
💡 Hint
Think about how mixins help with repetitive code.
❓ selector
advanced
1:30remaining
Which selector is targeted by this Sass mixin usage?
Given this Sass code, which CSS selector will the styles apply to?
@mixin user-select($value) {
  -webkit-user-select: $value;
  -moz-user-select: $value;
  -ms-user-select: $value;
  user-select: $value;
}

button {
  @include user-select(none);
}
SASS
@mixin user-select($value) {
  -webkit-user-select: $value;
  -moz-user-select: $value;
  -ms-user-select: $value;
  user-select: $value;
}

button {
  @include user-select(none);
}
AOnly <button> elements with class 'user-select'
BOnly <button> elements inside a container with class 'user-select'
CAll <button> elements on the page
DAll elements with attribute user-select='none'
Attempts:
2 left
💡 Hint
Look at the selector before the mixin usage.
❓ layout
advanced
2:00remaining
How does this vendor prefix mixin affect layout rendering?
Consider this Sass mixin and usage:
@mixin flex-center {
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  justify-content: center;
  align-items: center;
}

.container {
  @include flex-center;
  height: 200px;
}

What visual effect will the container have?
SASS
@mixin flex-center {
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  justify-content: center;
  align-items: center;
}

.container {
  @include flex-center;
  height: 200px;
}
AThe container will center its child elements horizontally and vertically within 200px height.
BThe container will stack child elements vertically without centering.
CThe container will hide child elements due to conflicting display properties.
DThe container will scroll child elements horizontally.
Attempts:
2 left
💡 Hint
Think about what flexbox centering does.
❓ accessibility
expert
2:30remaining
Which vendor prefix mixin usage best supports accessibility for focus outlines?
Which Sass mixin usage ensures consistent focus outlines across browsers for accessibility?
@mixin focus-outline($color) {
  outline: 2px solid $color;
  outline-offset: 2px;
  -webkit-outline-offset: 2px;
}

Choose the correct usage:
SASS
@mixin focus-outline($color) {
  outline: 2px solid $color;
  outline-offset: 2px;
  -webkit-outline-offset: 2px;
}

input:focus {
  @include focus-outline(blue);
}
Ainput:focus { @include focus-outline(blue); }
Binput:focus-visible { @include focus-outline(blue); }
Cinput { @include focus-outline(blue); }
Dinput:hover { @include focus-outline(blue); }
Attempts:
2 left
💡 Hint
Focus outlines should appear only when keyboard focusing, not on hover.

Practice

(1/5)
1. What is the main purpose of using a vendor prefix mixin in Sass?
easy
A. To add browser-specific prefixes automatically for better compatibility
B. To create animations without writing keyframes
C. To import external CSS files into Sass
D. To define variables for colors and fonts

Solution

  1. Step 1: Understand vendor prefixes

    Vendor prefixes are added to CSS properties to ensure they work in different browsers that may require special syntax.
  2. Step 2: Role of mixins in Sass

    Mixins let you write code once and reuse it, so a vendor prefix mixin adds all needed prefixes automatically wherever used.
  3. Final Answer:

    To add browser-specific prefixes automatically for better compatibility -> Option A
  4. Quick Check:

    Vendor prefix mixin = add prefixes automatically [OK]
Hint: Think: mixins reuse prefix code for all browsers [OK]
Common Mistakes:
  • Confusing mixins with variables
  • Thinking mixins import files
  • Believing mixins create animations
2. Which of the following is the correct syntax to define a vendor prefix mixin for transform in Sass?
easy
A. @mixin transform($value) { -webkit-transform: $value; -moz-transform: $value; -ms-transform: $value; }
B. @mixin transform($value) { transform: $value; -webkit-transform: $value; -moz-transform: $value; }
C. @mixin transform { -webkit-transform: $value; -moz-transform: $value; transform: $value; }
D. @mixin transform($value) { -webkit-transform: $value; -moz-transform: $value; transform: $value; }

Solution

  1. Step 1: Check mixin parameter usage

    The mixin must accept a parameter ($value) to apply the transform value.
  2. Step 2: Verify property order and completeness

    @mixin transform($value) { -webkit-transform: $value; -moz-transform: $value; transform: $value; } correctly includes -webkit-, -moz-, and the standard transform property in proper syntax and order.
  3. Final Answer:

    @mixin transform($value) { -webkit-transform: $value; -moz-transform: $value; transform: $value; } -> Option D
  4. Quick Check:

    Correct mixin syntax with parameter and prefixes = D [OK]
Hint: Always include parameter and standard property last [OK]
Common Mistakes:
  • Omitting the parameter in mixin definition
  • Wrong order of properties
  • Missing the standard property without prefix
3. Given the following Sass code, what CSS will be generated?
@mixin user-select($value) {
  -webkit-user-select: $value;
  -moz-user-select: $value;
  -ms-user-select: $value;
  user-select: $value;
}

.button {
  @include user-select(none);
}
medium
A. .button { user-select: none; -webkit-user-select: none; -moz-user-select: none; -ms-user-select: none; }
B. .button { -webkit-user-select: none; user-select: none; }
C. .button { -webkit-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none; }
D. .button { -webkit-user-select: none; -moz-user-select: none; user-select: none; }

Solution

  1. Step 1: Understand mixin expansion

    The mixin includes all vendor prefixes and the standard property with the passed value 'none'.
  2. Step 2: Check output order and completeness

    The generated CSS will list all prefixes and the standard property exactly as in the mixin, inside the .button selector.
  3. Final Answer:

    .button { -webkit-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none; } -> Option C
  4. Quick Check:

    Mixin expands all prefixes + standard = B [OK]
Hint: Mixin outputs all prefixes in order used [OK]
Common Mistakes:
  • Missing some vendor prefixes
  • Changing property order incorrectly
  • Omitting the standard property
4. Identify the error in this vendor prefix mixin and choose the fix:
@mixin box-shadow($shadow) {
  -webkit-box-shadow: $shadow;
  -moz-box-shadow: $shadow
  box-shadow: $shadow;
}
medium
A. Remove the parameter $shadow from mixin
B. Add a semicolon after '-moz-box-shadow: $shadow;'
C. Change mixin to a function
D. Add quotes around $shadow values

Solution

  1. Step 1: Check syntax line by line

    The line '-moz-box-shadow: $shadow' is missing a semicolon at the end, causing a syntax error.
  2. Step 2: Fix syntax error

    Adding the missing semicolon after '-moz-box-shadow: $shadow;' corrects the mixin syntax.
  3. Final Answer:

    Add a semicolon after '-moz-box-shadow: $shadow;' -> Option B
  4. Quick Check:

    Missing semicolon causes error = fix by adding it [OK]
Hint: Check each property line ends with semicolon [OK]
Common Mistakes:
  • Ignoring missing semicolon errors
  • Thinking parameters are wrong
  • Confusing mixins with functions
5. You want to create a Sass mixin that adds vendor prefixes for display: flex and also sets flex-direction. Which is the best way to write this mixin?
hard
A. @mixin flex-container($direction) { display: -webkit-box; display: -ms-flexbox; display: flex; -webkit-flex-direction: $direction; -ms-flex-direction: $direction; flex-direction: $direction; }
B. @mixin flex-container($direction) { display: flex; flex-direction: $direction; }
C. @mixin flex-container { display: flex; flex-direction: row; }
D. @mixin flex-container($direction) { display: -webkit-flex; display: flex; flex-direction: $direction; }

Solution

  1. Step 1: Include all necessary vendor prefixes for display flex

    @mixin flex-container($direction) { display: -webkit-box; display: -ms-flexbox; display: flex; -webkit-flex-direction: $direction; -ms-flex-direction: $direction; flex-direction: $direction; } includes -webkit-box and -ms-flexbox for older browsers, plus standard flex.
  2. Step 2: Add vendor prefixes for flex-direction with parameter

    @mixin flex-container($direction) { display: -webkit-box; display: -ms-flexbox; display: flex; -webkit-flex-direction: $direction; -ms-flex-direction: $direction; flex-direction: $direction; } also prefixes flex-direction for -webkit- and -ms- with the passed $direction value.
  3. Final Answer:

    @mixin flex-container($direction) { display: -webkit-box; display: -ms-flexbox; display: flex; -webkit-flex-direction: $direction; -ms-flex-direction: $direction; flex-direction: $direction; } -> Option A
  4. Quick Check:

    Complete prefixes for display and flex-direction = A [OK]
Hint: Prefix both display and flex-direction with parameter [OK]
Common Mistakes:
  • Omitting older browser prefixes
  • Not using parameter for direction
  • Using incomplete prefix sets
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard