Jump to content
Search Community

Force content to be shown in a div

theokam test
Moderator Tag

Warning: Please note

This thread was started before GSAP 3 was released. Some information, especially the syntax, may be out of date for GSAP 3. Please see the GSAP 3 migration guide and release notes for more information about how to update the code to GSAP 3's syntax. 

Recommended Posts

I'm stuck and I need help. I'm using superscrollorama and tweenmax. I got a 12000 px div that is scrolling horizontally showing some products. I want to know if there's a way to force the content of this div to be shown only in a centered 1000px div, maybe something in the tweenlite api.. Can someone help me? Thanks!!

Link to comment
Share on other sites

Hi and welcome to the forums.


Put all your content inside that div. Give the div element an overflow:hidden property, like that the content won't appear outside the boundaries of the element; also give all the elements (the parent or container DIV and it's contents) a position:fixed value. You can use that and set superscrollorama to trigger the animations based on the scroll position in px and not the elements offset.


Finally to center your div you can use the following code:

var center = function(elemID)
        "left" , ((($(window).width() - elemID.outerWidth()) / 2) + "px")


Also you could use GSAP to set the position, like this:

var center = (($(window).width() - elemID.outerWidth()) / 2),
    yourElement = $("div#yourElementID");

TweenLite.set(yourElement, {left:center});

Hope this helps,


  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...