Created
October 25, 2012 00:16
-
-
Save scottbaggett/3949763 to your computer and use it in GitHub Desktop.
center items inside edge animation
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
| // Add the 'center' class to any element you want to center on resize. | |
| // Using this in combination with the scale-background mode will make backgrounds | |
| // work on all sizes, Yay! | |
| var $center_items = $(".center"); | |
| var center; | |
| window.resize = function() { | |
| console.log("resize"); | |
| $center_items.each(function(i,el){ | |
| center = $(window).width() / 2 - $(el).width() / 2; | |
| console.log($(window).width()); | |
| $(el).css({ | |
| "left":center | |
| }); | |
| }); | |
| } | |
| $(window).resize(window.resize); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
ok so i add the class i get that after reading it again.. where do i plug this code in tho?