【发布时间】:2018-09-17 00:17:47
【问题描述】:
我正在尝试为一个小矩形 div 设置动画,该 div 居中/固定在屏幕顶部,并将从中心缩放到全屏覆盖。这是我正在尝试创建的动画的线框图。
我现在有一个解决方案,但它绝对不是最干净或最优雅的:
<div class="step1"></div>
.step1 {
border:none;
background:none;
text-align: Center;
font-size: 1.6em;
height: 200px;
width: 300px;
background-color: blue;
position: fixed;
left: 47%;
margin-left: -1.75em;
top: 0;
z-index: 1;
transition: all .2s;
}
.step2 {
height: 100%;
width: 100%;
left: 0%;
top: 0;
margin: 0;
border:none;
background:none;
color: white;
text-align: Center;
background-color: blue;
position: fixed;
z-index: 1;
border-radius: 0;
}
我也得到了一个 janky 动画,我知道一定有更好的方法。谁能提供更清洁的解决方案?
【问题讨论】:
-
您的解决方案在哪里?你能用你的解决方案更新sn-p吗
-
究竟是如何触发动画的?
-
我正在使用 React,所以复制所有代码真的很困难。不过,这只是一个简单的切换类。
标签: javascript jquery css css-transitions