Forked from corydorning/Cross-Browser ::before and ::after pseudo-class polyfill
Created
August 14, 2012 14:41
-
-
Save thealscott/3349897 to your computer and use it in GitHub Desktop.
Cross-Browser ::before and ::after pseudo-class polyfill - adapted into mixins for SCSS using modernizr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@mixin after-polyfill(){ | |
.ie7 & { | |
/* creates <span class="ie-after"></span> */ | |
zoom: expression( this.runtimeStyle.zoom="1", this.appendChild( document.createElement("span") ).className="ie-after" ); | |
} | |
} | |
@mixin before-polyfill(){ | |
.ie7 & { | |
/* creates <span class="ie-before"></span> */ | |
zoom: expression( this.runtimeStyle.zoom="1", this.insertBefore( document.createElement("span"), this.firstChild ).className="ie-before" ); | |
} | |
} | |
@mixin before-and-after-polyfill(){ | |
.ie7 & { | |
/* creates <span class="ie-before"></span> */ | |
zoom: expression( | |
this.runtimeStyle.zoom="1", | |
this.insertBefore( document.createElement("span"), this.firstChild ).className="ie-before", | |
this.appendChild( document.createElement("span") ).className="ie-after" | |
); | |
} | |
} | |
/* | |
USAGE | |
*/ | |
div { | |
@include after-polyfill(); | |
& .ie-after, | |
&:after { | |
/*CSS*/ | |
} | |
} | |
div { | |
@include before-polyfill(); | |
& .ie-before, | |
&:before { | |
/*CSS*/ | |
} | |
} | |
div { | |
@include before-and-after-polyfill(); | |
& .ie-before, | |
&:before { | |
/*CSS*/ | |
} | |
& .ie-after, | |
&:after { | |
/*CSS*/ | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment