I am extremely new to Sass/Compass, so this question may sound dumb to many of you.
Anyway, what I need to know is how to create a mixin for browser vendor prefixes that I can reuse over and over without having to type them every time.
I've seen tutorials online but I just can't understand some of the concepts I need to be able to apply them correctly.
What I need right now is to accomplish this in CSS:
* {
-webkit-box-sizing:border-box;
-moz-box-sizing:border-box;
-ms-box-sizing:border-box;
-o-box-sizing:border-box;
box-sizing:border-box;
}
Thanks.
Sounds like you want to use the Compass box-sizing mixin. Your SASS file would look like this:
And would compile to this:
You can see the other CSS3 Compass mixins here. Note, though, that Compass doesn't include prefixes like
-ms-box-sizing
, for instance, since IE8+ has implemented it without a prefix. If you really want those extra properties, this is how you'd do it:I would encourage you to try writing your own mixins. Here is the one I am using for browser prefixes.
Then you can use it by simply typing (using box-sizing as an example):
Results in the following CSS:
If you need to pass more than one value, you can use parentheses (useful for transitions):
Results in the following CSS: