<div class="container">
  <div class="box"></div>
</div>

<div class="container container--large">
  <div class="box"></div>
</div>
body {
  display: flex;
  align-items: center;
  justify-content: space-around;
  min-height: 100vh;
}

.container {
  display: flex;
  align-items: center;
  border: solid 2px white;
  width: 30vw;
  height: 80vh;
  container-type: inline-size;
}

.container--large {
  width: 60vw;
}

.box {
  width: 20cqw;
  height: 20cqw;
}
// Easily animate across the parent element

gsap.to('.box', {
  x: '100cqw',
  xPercent: -100,
  yoyo: true,
  repeat: -1,
  duration: 2,
  ease: 'power2.inOut'
})
Run Pen

External CSS

  1. https://codepen.io/GreenSock/pen/gOWxmWG.css

External JavaScript

  1. https://unpkg.co/gsap@3/dist/gsap.min.js
  2. https://unpkg.com/gsap@3/dist/CSSRulePlugin.min.js
  3. https://assets.codepen.io/16327/CustomBounce3.min.js
  4. https://assets.codepen.io/16327/CustomEase3.min.js
  5. https://assets.codepen.io/16327/CustomWiggle3.min.js
  6. https://assets.codepen.io/16327/DrawSVGPlugin3.min.js
  7. https://unpkg.com/gsap@3/dist/Draggable.min.js
  8. https://unpkg.com/gsap@3/dist/EaselPlugin.min.js
  9. https://unpkg.com/gsap@3/dist/EasePack.min.js
  10. https://assets.codepen.io/16327/Flip.min.js
  11. https://assets.codepen.io/16327/GSDevTools3.min.js
  12. https://assets.codepen.io/16327/InertiaPlugin.min.js
  13. https://assets.codepen.io/16327/MorphSVGPlugin3.min.js
  14. https://unpkg.com/gsap@3/dist/MotionPathPlugin.min.js
  15. https://assets.codepen.io/16327/MotionPathHelper.min.js
  16. https://assets.codepen.io/16327/PhysicsPropsPlugin3.min.js
  17. https://assets.codepen.io/16327/Physics2DPlugin3.min.js
  18. https://unpkg.com/gsap@3/dist/PixiPlugin.min.js
  19. https://assets.codepen.io/16327/ScrambleTextPlugin3.min.js
  20. https://unpkg.com/gsap@3/dist/ScrollToPlugin.min.js
  21. https://unpkg.com/gsap@3/dist/ScrollTrigger.min.js
  22. https://assets.codepen.io/16327/SplitText3.min.js
  23. https://unpkg.com/gsap@3/dist/TextPlugin.min.js
  24. https://assets.codepen.io/16327/ScrollSmoother.min.js
  25. https://unpkg.com/gsap/dist/Observer.min.js