Created
March 8, 2013 20:06
-
-
Save bcullen/5119448 to your computer and use it in GitHub Desktop.
Quick & dirty hack for an element absolutely positioned with CSS calc() in IE8
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
| // For .element {right: -webkit-calc(50% - 510px); right: calc(50% - 510px);} | |
| $(document).ready(function() { | |
| calcHack(); | |
| $(window).resize(calcHack); | |
| function calcHack() { | |
| var windowWidth = $(window).width(); | |
| var offset = 510; | |
| var position = (windowWidth /2) - offset; | |
| $('.element').css({ | |
| 'right': position + 'px' | |
| }); | |
| } | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment