模态动画问题
Modal Animation issue
我正在尝试使用 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
位置top
和left
#container {
position: fixed;
display: table;
height: 100%;
width: 100%;
top: -100%;
left: 0;
z-index: 1;
}
它可能对你有帮助,这是我针对你的问题的代码
Codepen
我正在尝试使用 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
位置top
和left
#container {
position: fixed;
display: table;
height: 100%;
width: 100%;
top: -100%;
left: 0;
z-index: 1;
}
它可能对你有帮助,这是我针对你的问题的代码 Codepen