css 完成后保持动画

标签 css

例如,我将比例从 1 调整为 2,我想让它在比例达到 2 时保持不变,例如,当用户将鼠标悬停在某个图像上时,它会被缩放,这可能吗?

@-webkit-keyframes scale {
    from {
        transform: scale(1);
        -ms-transform: scale(1); /* IE 9 */
        -webkit-transform: scale(1); /* Safari and Chrome */
    }
    to {
        transform: scale(1.5);
        -ms-transform: scale(1.5); /* IE 9 */
        -webkit-transform: scale(1.5); /* Safari and Chrome */
    }
}
@keyframes scale {
    from {
        transform: scale(1);
        -ms-transform: scale(1); /* IE 9 */
        -webkit-transform: scale(1); /* Safari and Chrome */
    }
    to {
        transform: scale(1.5);
        -ms-transform: scale(1.5); /* IE 9 */
        -webkit-transform: scale(1.5); /* Safari and Chrome */
    }
}

div.item:hover
{
animation: scale 2s;
-webkit-animation: scale 2s;
}

最佳答案

使用animation-fill-mode:forwards or both

div.item:hover
{
animation: scale 2s forwards;
-webkit-animation: scale 2s forwards;
}

关于css 完成后保持动画,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16213542/

相关文章:

css - 如何在 SASS 中创建一个可以接受键并返回所有祖先列表的递归函数?

Javascript 与 C# 在 ASP.NET 4.5 MVC 中动态更改元素类/id

css - 初始化时 Masonry Grid Broken Layout

html - 如何使此 html 两列宽度相等且中间有边距?

css - Bootstrap 响应式导航栏仅在手机模式下折叠(无平板电脑模式)

javascript - 关于... Z-索引?

html - 导航栏下拉菜单不起作用 Bootstrap 下拉 anchor 在单击时不起作用

css - 控制台中的 Bootstrap css 错误

css - 为新手使用 CSS 预处理器

html - 如何修复显示 : inline-flex scaling problem?