Skip to content

Instantly share code, notes, and snippets.

@sou5534
Last active June 15, 2021 06:14
Show Gist options
  • Save sou5534/025a6938f379c299d116584f668b6d67 to your computer and use it in GitHub Desktop.
Save sou5534/025a6938f379c299d116584f668b6d67 to your computer and use it in GitHub Desktop.
Sass(SCSS)でIEハックのmixin設定
/* IEハック用mixin */
@mixin hack($IE-ver: null) {
@if $IE-ver == 'lteIE8' { // IE8以下
@media \0screen\,screen\9 {
@content;
}
}
@else if $IE-ver == 'gteIE9' { // IE9以上
@media screen and (min-width:0\0) {
@content;
}
}
@else if $IE-ver == 'gteIE10' { // IE10以上
@media screen and (-ms-high-contrast: active), (-ms-high-contrast: none) {
@content;
}
}
@else if $IE-ver == 'gteIE11' { // IE11以上
@at-root _:-ms-fullscreen,:root & {
@content;
}
}
@else if $IE-ver == 'notIE8' { // IE8じゃないとき(他のブラウザも含める)
@media all and (min-width: 0) {
@content;
}
}
}
@media \0screen\,screen\9 { /* IE8以下 */
.is-lteIE8 {
color: red;
}
}
@media screen and (min-width: 0\0) { /* IE9以上 */
.is-gteIE9 {
color: red;
}
}
@media screen and (-ms-high-contrast: active), (-ms-high-contrast: none) { /* IE10以上 */
.is-gteIE10 {
color: red;
}
}
_:-ms-fullscreen, :root .is-gteIE11 { /* IE11以上 */
color: red;
}
@media all and (min-width: 0) { /* IE8じゃないとき(他のブラウザも含める) */
.is-notIE8 {
color: red;
}
}
.is-lteIE8 {
@include hack(lteIE8){ /* IE8以下 */
color: red;
}
}
.is-gteIE9 {
@include hack(gteIE9){ /* IE9以上 */
color: red;
}
}
.is-gteIE10 {
@include hack(gteIE10){ /* IE10以上 */
color: red;
}
}
.is-gteIE11 {
@include hack(gteIE11){ /* IE11以上 */
color: red;
}
}
.is-notIE8 {
@include hack(notIE8){ /* IE8じゃないとき(他のブラウザも含める) */
color: red;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment