Last active
November 4, 2015 08:15
-
-
Save akkijp/7b3ede55a5ca0c59ee8d to your computer and use it in GitHub Desktop.
windowの幅を狭くしたときに、window positionが中心になりながら狭くなっていくスクリプト
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
$(function(){ | |
var $window = $(window), | |
$document = $(document); | |
$(window).on('resize', function(){ | |
var wwidth = $window.width(), | |
dwidth = $document.width(); | |
(wwidth < dwidth) && $document.scrollLeft( (dwidth - wwidth)/2 ) | |
}); | |
$(window).trigger('resize'); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment