作者:Just忽略我_559 | 来源:互联网 | 2023-05-18 11:20
HowCanIfixthebelowcode..Ihaveusedthetechniqueoftransform:translateY(-50%)tomakeadiv
How Can I fix the below code.. I have used the technique of transform:translateY(-50%) to make a div vertically center. But When I use it with animation , it first takes top:50%
then it translates giving a jerk.. I don't want the jerk to happen and the element should automatically come in center.
我怎样才能修改下面的代码。我使用了转换技术:translateY(-50%)来创建一个div垂直中心。但当我在动画中使用它时,它首先会占据顶部:50%然后它会翻译为“给一个混蛋”。我不希望这种情况发生,元素应该自动进入中心。
body,
html {
height: 100%;
background: #c9edff;
text-align: center;
}
.element {
position: relative;
top: 50%;
transform: translateY(-50%);
font-family: arial;
font-size: 20px;
line-height: 1.8em;
-webkit-animation-name: zoom;
-webkit-animation-duration: 0.6s;
animation-name: zoom;
animation-duration: 0.6s;
}
@-webkit-keyframes zoom {
from {
-webkit-transform: scale(0);
}
to {
-webkit-transform: scale(1)
}
}
@keyframes zoom {
from {
transform: scale(0)
}
to {
transform: scale(1)
}
}
Vertical Align is Awesome!
But with animation its giving a jerk!
Please Fix
2 个解决方案