A vendor prefix is a special code added before CSS properties to ensure they work in specific browsers. Examples include -webkit- for Chrome and Safari, -moz- for Firefox, and -ms- for Internet Explorer.
Click to reveal answer
beginner
Why use mixins for vendor prefixes in Sass?
Mixins let you write vendor prefixes once and reuse them everywhere. This saves time, avoids mistakes, and keeps your code clean and easy to update.
Click to reveal answer
beginner
Example of a simple vendor prefix mixin for border-radius in Sass?
The mixin must accept a parameter ($value) to apply the transform value.
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.
B. Add a semicolon after '-moz-box-shadow: $shadow;'
C. Change mixin to a function
D. Add quotes around $shadow values
Solution
Step 1: Check syntax line by line
The line '-moz-box-shadow: $shadow' is missing a semicolon at the end, causing a syntax error.
Step 2: Fix syntax error
Adding the missing semicolon after '-moz-box-shadow: $shadow;' corrects the mixin syntax.
Final Answer:
Add a semicolon after '-moz-box-shadow: $shadow;' -> Option B
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?