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); |
ok so i add the class i get that after reading it again.. where do i plug this code in tho?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
hii.. uber noober here. I created a website. And i need the items centered.. accidently stumbled upon your code.. but no idea how to add these functions to the individual items..
i know you can add a general code with composition ready. but thats only for stage. do i add this in the actual .js files?
thanks in advance.
this is the site if your curious.
www.designwave.ca