模态动画问题



我正在尝试使用Tweenmax获得模态动画。它目前可以动画化,但我遇到的问题是我希望它从屏幕顶部到中间进行动画化并停在那里。目前,它只是动画到中间。

.HTML:

<button onclick="clickButton();">Testing</button>
<div id="container">
  <div class="background">
    <div class="modal">
      <h2>Testing Modal</h2>
      <p>Testing.</p>
    </div>
  </div>
</div>

.JS:

clickButton = function() {
  TweenMax.to("#container", 0.3, {
    className: "+=active",
    ease: Power1.easeOut
  });
};

我尝试使用CSS来执行此操作:

#modal-container .modal-background {
  display: table-cell;
  background: rgba(0, 0, 0, 0.8);
  text-align: center;
  vertical-align: top;
}
#modal-container.active .modal-background {
    vertical-align: center;
}

代码笔

像这样更改transform

#container.active {
    transform: translateY(100%);
}

您的#container位置topleft

#container {
    position: fixed;
    display: table;
    height: 100%;
    width: 100%;
    top: -100%;
    left: 0;
    z-index: 1;
}

它可能会对您有所帮助,这是我针对您的问题的代码代码笔

最新更新