Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialMarcus Tisäter
4,886 PointsAdding important property to sass mixin
hey
I made this mixin
@mixin block($color,$font-size,$font-weight) {
color: $color;
font-size: $font-size;
font-weight: $font-weight;
}
I include the mixin...
@include block(blue,15px,bold);
I want to add the !important property for the color, I dont know how to input it, i keep getting SASS syntax errors. Any ideas?
6 Answers
Yaswanth Goli
6,872 Pointskeep semi-colon at font-weight
Marcus Tisäter
4,886 PointsYou can include the !important throughout the include by doing this
@include block(blue !important,15px,bold);
Can you do it at a mixin?
Yaswanth Goli
6,872 Pointstry
@mixin block($color,$font-size,$font-weight) {
color: $color !important;
font-size: $font-size;
font-weight: $font-weight;
}
Marcus Tisäter
4,886 PointsThat worked... It's wired becuase in CSS you have to use : after a property value to include !import ...
Wayne Priestley
19,579 PointsHey Marcus,
I'm curious as to the reason for needing !important in your mixin, I assume that being a mixin you intend to use this a lot, so are you running into a problem getting the colour to apply without !important?
cheers
Marcus Tisäter
4,886 PointsIt's a long story.. , but I need the !important to overwrite a diffrent colour set that keeps being primary. I manage to get it work now!
Marcus Tisäter
4,886 PointsMarcus Tisäter
4,886 PointsThat was not my question
Marcus Tisäter
4,886 PointsMarcus Tisäter
4,886 Pointsbut thanks anyway..