jquery - 如何使用显示:none on the end of a css-animation

标签 jquery css animation

我想在关键帧动画的末尾添加一个 display:none 属性。就像这样:

.sw_intro{
    animation: introtop;
    animation-duration: 0.8s;
    animation-delay: 2s;
    animation-fill-mode: forwards;
}

@keyframes introtop {
    0% {margin-top: 0;display: block;}
    100%{display: none;margin-top: 100vh;}
}

但是 display:none-property 没有被使用。我认为这不是我的“代码”的错误,而是不允许/可行的错误。虽然我希望在动画结束时具有这种效果,并且它必须类似于 display:none 效果,而不是 opacity:0;

我怎样才能做到/实现这一目标?用 jquery 代替?

谢谢!

最佳答案

display 不是适用于动画的属性。相反,您可以将尺寸(heightwidth)更改为 0 并将 overflow:hidden; 设置为元素。这样,该元素实际上应该从页面中消失。

.sw_intro{
    display:block;
    overflow:hidden;
    animation: introtop;
    animation-duration: 0.8s;
    animation-delay: 2s;
    animation-fill-mode: forwards;
}

@keyframes introtop {
    0% {margin-top: 0; width:inherit; height:inherit;}
    100%{margin-top: 100vh; width:0; height:0;}
}

关于jquery - 如何使用显示:none on the end of a css-animation,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42278600/

相关文章:

javascript - jquery removeClass 似乎不起作用

jquery - slider (旋转木马)与其他元素对齐

javascript - onchange 事件监听器未在文本框上触发

css - iOS7 Safari 更改 webkit-overflow-scrolling 背景颜色

iphone - 顺序 UIView 变换

java - 动画听众,听谁的?

android - built-in Animation 适合长时间运行的慢动画吗?

javascript - 自动删除图像并重新排列 ID 号

javascript - 是否可以将类添加到伪元素?

html - 如何扩展父级 Div 高度以填充其包含的父级