我try 执行下面的动画,它基本上包括提高锁,使它旋转,然后下降.我希望这件事按比例做.然而,即使使用低得多的下降百分比,动画似乎在2s中执行前两个步骤,并在剩余的2s中执行下降.

@keyframes float {
    0%,3% {

        transform: translatey(0px);
    }
    3%, 6% {

        transform: translatey(-4px);
    }
    
    6%, 30%{
        transform: rotateY(0deg) translatey(-4px);
    }
    30%, 94%{
        transform: rotateY(1080deg) translatey(-4px);
    }

    94%, 100%{
        transform: translatey(0px);
    }
}

.square {
    
    animation: float linear infinite;
    animation-duration: 4s;
}

div {
    perspective: 500px; 
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 44px;
}

.cadeado{
    background-image: url(https://www.qas.flyembraer.com/irj/go/km/docs/download_center/Anonymous/loading-sem-cadeado.jpg);
    width: 144px;
    height: 144px;
    align:center;
}
<div class="cadeado">
<div class ="square"><img src="https://www.qas.flyembraer.com/irj/go/km/docs/download_center/Anonymous/cadeado.jpg" alt="" align="center"></div>
</div>

I've tried setting the proportional % to 33% for each step but it still doesn't work

推荐答案

我发现镜像动画是有帮助的.这离你要找的更近吗

@keyframes float {
    0%,10% {

        transform: translatey(0px);
    }
    10%, 20% {

        transform: translatey(-4px);
    }
    
    20%, 60%{
        transform: rotateY(0deg) translatey(-4px);
    }
    60%, 80%{
        transform: rotateY(1080deg) translatey(-4px);
    }
    80%, 90% {
        transform: translatey(-4px);
    }

    90%, 100%{
        transform: translatey(0px);
    }
}

.square {
    
    animation: float linear infinite;
    animation-duration: 5s;
}

div {
    perspective: 500px; 
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 44px;
}

.cadeado{
    background-image: url(https://www.qas.flyembraer.com/irj/go/km/docs/download_center/Anonymous/loading-sem-cadeado.jpg);
    width: 144px;
    height: 144px;
    align:center;
}
<div class="cadeado">
<div class ="square"><img src="https://www.qas.flyembraer.com/irj/go/km/docs/download_center/Anonymous/cadeado.jpg" alt="" align="center"></div>
</div>

Css相关问答推荐

自定义kendo色彩 Select 器中的清晰按钮

Safari CSS扫描动画效果不起作用

如何在react 路由中设置活动类?

Angular 17 Animation -在幻灯片左/右两侧同步

在主零部件悬停上对子零部件设置Angular 样式

使用tailwind 将父div限制为其具有溢出的最短子级的高度

如何使用 Tailwind CSS 稳定 React 中的浮动标签?

在 React Native 中创建背景

网格在行方向上的大小不正确

CSS中元素的重叠

整个列的 CSS Grid Margin Top

使用 styled-components,我如何定位组件的子类?

我应该在 HTML 中为我的 IMG 指定高度和宽度属性吗?

在固定高度的输入字段中垂直对齐文本而不显示:表格或填充?

在 Firefox 中删除额外的按钮间距/填充

CSS:在图像周围创建白光

Chrome 呈现 colored颜色 的方式与 Safari 和 Firefox 不同

谷歌浏览器两种元素样式的区别

Angular 动画的目的是什么?

当子元素水平溢出时,为什么忽略父元素的右填充?