Jump to content
Search Community

Need Child Div to Grow 100% of Parent Div

rubybuilds 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

Hi all,


So I am attempting to make it so my child grows into its parent. I have my wrapper div's margins set to 5vw so that I have a perfect border all around my browser.


The issue seems to be when I click the div and the animation starts, it ignores the margins set there and expands past the wrapper's containment field.


What am I not seeing?


Thanks in advance!

See the Pen ooJWdq by msolaridesign (@msolaridesign) on CodePen

Link to comment
Share on other sites

Hi @msolari


You're giving the element conflicting dimensions. It's position is fixed, so setting the width and height to 100% will fill the screen. But then you're telling it that every side has to be 5vw away from the edge of the screen. The browser had to make a choice, and it went with ignoring the right and bottom values. So to fix it, you don't need the width and height.


There's one problem though. You set the width and height in your CSS, so you need to unset those values.


TweenMax.to('.one', 1, {
  top: '5vw',
  left: '5vw',
  bottom: '5vw',
  right: '5vw',
  width: 'unset',
  height: 'unset',



  • Like 3
  • Thanks 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...