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.
CSS prefixes -webkit- (Chrome, Safari, newer versions of Opera, almost all iOS browsers including Firefox for iOS; basically, any WebKit based browser) -moz- (Firefox) -o- (old pre-WebKit versions of Opera) -ms- (Internet Explorer and Microsoft Edge)
I also wanted to abstract out vendor prefixes but didn't have compass available to me.
@mixin vendor-prefix($name, $value) { @each $vendor in ('-webkit-', '-moz-', '-ms-', '-o-', '') { #{$vendor}#{$name}: #{$value}; } }
Sass:
* { @include vendor-prefix('box-sizing', 'border-box'); }
Renders:
* { -webkit-box-sizing: border-box; -moz-box-sizing: border-box; -ms-box-sizing: border-box; -o-box-sizing: border-box; box-sizing: border-box; }
Also see:
http://stefanwienert.net/blog/2012/05/18/easy-css-vendor-prefix-mixin-for-sass/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With