Skip to content

Instantly share code, notes, and snippets.

@dieppon
Created May 21, 2019 10:37
Show Gist options
  • Select an option

  • Save dieppon/063fdf5420db587acc29d6552c691afd to your computer and use it in GitHub Desktop.

Select an option

Save dieppon/063fdf5420db587acc29d6552c691afd to your computer and use it in GitHub Desktop.
Target browsers with css
@mixin only-browser($browser) {
// Firefox
@if $browser == 'mozilla' or $browser == 'firefox' {
@-moz-document url-prefix() { @content; }
}
// IE
@if $browser == 'ie' {
@media screen and (-ms-high-contrast: active), (-ms-high-contrast: none) { @content; }
}
// Edge
@if $browser == 'edge' {
@supports (-ms-ime-align: auto) { @content; }
}
// Safari 9+
@if $browser == 'safari' {
@supports (-webkit-marquee-repetition:infinite) and (object-fit:fill) { @content; }
}
// Google Chrome
@if $browser == 'chrome' {
@supports (-webkit-appearance:none) and (not (overflow:-webkit-marquee)) and (not (-ms-ime-align:auto)) and (not (-moz-appearance:none)) { @content; }
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment