I wanna create a rule for safari browser only with sass. According to this answer I need
@media screen and (min-color-index:0) and(-webkit-min-device-pixel-ratio:0)
Notice there's no space after 2nd and, otherwise it triggers chrome.
So somewhere in my-file.sass
I do the following:
$safari-only: '(min-color-index:0) and(-webkit-min-device-pixel-ratio:0)'
@media screen and #{$safari-only}
body
background-image: linear-gradient(green 0%, red 100%) !important
But this thing compiles into
@media screen and (min-color-index: 0) and (-webkit-min-device-pixel-ratio: 0) {
body {
background-image: linear-gradient(green 0%, red 100%) !important;
}
}
Note, there IS a space after 2nd and. Here's the demo
Another thing I would like to know if I can create a @safari-only
mixin. For example:
@mixing safari-only
$safari-only: '(min-color-index:0) and(-webkit-min-device-pixel-ratio:0)'
@media screen and #{$safari-only}
@include safari-only
body
background-image: linear-gradient(green 0%, red 100%) !important
This produces an error that the mixin doesn't have a body
So I would like to know:
- How do I tell sass not formatting code instead of me?
- How can I create a first level selector as a mixin
p.s. I'm using Sass 3.4.21 (Selective Steve)
Best regards,