Last active
February 26, 2019 09:10
-
-
Save LeanSeverino1022/6b926797f34d46e06e449be37edebad7 to your computer and use it in GitHub Desktop.
Position horizontal scroll bar at center of DIV (jQuery (2.1.1))
This file contains 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
/*position horizontal scroll bar at center of DIV*/ | |
// useful when for example the min-width of a scrollable container is wider than the viewport. Like in the t-shirt demo proj, I wanted the user to see the center of the shirt on load, rather than have the user need to scroll | |
function centerHScrollBar(){ | |
var outerContent = $('.product-view'); | |
var innerContent = $('.pillow-contain-show'); | |
outerContent.scrollLeft( (innerContent.width() - outerContent.width()) / 2); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment