Jump to content
Search Community

Gsap 3d slider positioning between elements

iotron test
Moderator Tag

Recommended Posts

Hi,

 

Basically you have to set a dimension for the container since it's descendant has a position absolute set to it.

 

This seems to work:

HTML

<div class="section">section 1</div>
<div class="box">
  <div class="stage" id="stage">
    <div class="wrapper" id="wrapper">
      <div class="ring" id="ring">
        <div class="card-item"></div>
      </div>
    </div>
  </div>
</div>
<div class="section">section 2</div>

CSS

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

.section {
  width: 100%;
  height: 100vh;
  background: blue;
}

.box {
  position: relative;
  width: 100%;
  height: 100vh;
}
.stage,
.ring,
.card-item {
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
}

.stage {
  overflow: hidden;
  position: absolute;
}

.ring,
.card-item,
.wrapper {
  position: absolute;
}

.wrapper {
  perspective: 2000px;
  width: 310px;
  min-height: 400px;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
}

Happy Tweening!

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