Last active
December 15, 2015 18:19
-
-
Save dmitryshimkin/5303410 to your computer and use it in GitHub Desktop.
Less mixin to emulate :focus pseudo-class for IE7. Probably works under IE 5-6 (not tested). Based on one-time expression (executed only once, doesn't affect performance)
This file contains hidden or 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 */ | |
| .focus(@className: "focused") { | |
| behavior: ~"expression(function focus(el) { el.runtimeStyle.behavior = 'none'; var focusClass = ' @{className}'; el.onfocus = function() { el.className += (focusClass); }; el.onblur = function() { el.className = el.className.replace(new RegExp(focusClass, 'g'), ''); }; }(this))"; | |
| } | |
| /* usage */ | |
| .input { | |
| .focus("input_focused"); | |
| .input:focus, | |
| .input_focused { | |
| border-color: blue; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment