问题是你正在删除
translate
转型。
当您指定一个新的转换(动画中的转换)时,
覆盖
第一个,所以您需要将它们添加到同一个
transform
属性。就你而言
正在删除翻译
那是修复
中心
对齐方式:
@keyframes ripple_large {
0% {
transform: translate(-50%, -50%) scale(1) ;
}
75% {
transform: translate(-50%, -50%) scale(3) ;
opacity: 0.4;
}
100% {
transform:translate(-50%, -50%) scale(4) ;
opacity: 0;
}
}
.container {
position: relative;
display: inline-block;
margin: 10vmax;
}
.cat {
height: 20vmax;
}
.center-point {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
height: 10px;
width: 10px;
background: blue;
transform-origin:center;
}
.to-animate {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
border: 1px solid red;
height: 5vmax;
width: 5vmax;
}
.one {
-webkit-animation: ripple_large 2s linear 0s infinite;
animation: ripple_large 2s linear 0s infinite;
}
.two {
-webkit-animation: ripple_large 2s linear 1s infinite;
animation: ripple_large 2s linear 1s infinite;
}
<div class='container'>
<img src='http://www.catster.com/wp-content/uploads/2017/08/Pixiebob-cat.jpg' class='cat'>
<div class='center-point'>
</div>
<div class='to-animate one'></div>
<div class='to-animate two'></div>
</div>
更新
如前所述,最好使用其他方法将元素居中,而不是转换,以避免更改动画,因为这可以与其他元素一起使用。