Jump to content
Search Community

Why does "left" not work in codepen?

Ismail Hozain
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

Ismail Hozain
Posted

So my issue is that everything in my tweenMax is working except the left part - it is changing color and things are good but not the movement.Why is that happening?Thanks

 

See the Pen XzVvjO by ismailhozain (@ismailhozain) on CodePen.

Posted (edited)

I see your issue. The <a> element needs to be `position: relative` and you need to tween that element's `left` property. Currently you are tweening the button that is inside <a>. 

 

Refer to css docs for when "left" can be used:

Quote
  • When position is set to absolute or fixed, the left property specifies the distance between the element's left edge and the left edge of its containing block. (The containing block is the ancestor to which the element is relatively positioned.)
  • When position is set to relative, the left property specifies the distance the element's left edge is moved to the right from its normal position.
  • When position is set to sticky, the left property behaves like its position is relative when the element is inside the viewport, and like its position is fixed when it is outside.
  • When position is set to static, the left property has no effect.

 

See the Pen gXVgGG by jmca (@jmca) on CodePen.

 

Edited by jmca
Adding pen
  • Like 4
  • Thanks 1
Ismail Hozain
Posted

Thank you very much, it worked well and achieved the look that I wanted!

  • Like 1

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...