简体   繁体   English

CSS3 - 几秒钟后显示一个元素

[英]CSS3 - Display an element after a few seconds

I'm using a pure CSS3 AJAX loader animation, however, I'm hoping to modify it a little. 我正在使用纯CSS3 AJAX加载器动画,但是,我希望稍微修改它。

Currently it just spins several balls in a circle, however, I'd like to display a message after about 30 seconds to please continue waiting and after about 60 seconds display another message that things might have failed. 目前它只旋转几个球,但是,我想在大约30秒后显示一条消息,请继续等待,大约60秒后显示另一条信息,表明事情可能已经失败。

Is it possible to accomplish this with pure CSS3? 是否有可能用纯CSS3实现这一目标? Or would JavaScript be required to get this done? 或者需要JavaScript才能完成这项工作?

this is a pure CSS3 animation effect JSFiddle 这是一个纯粹的CSS3动画效果JSFiddle

.animate {
    -webkit-animation: NAME-YOUR-ANIMATION 60s;
    -moz-animation: NAME-YOUR-ANIMATION 60s;
    -o-animation: NAME-YOUR-ANIMATION 60s;
    animation: NAME-YOUR-ANIMATION 60s;
    opacity: 0;
}
@keyframes NAME-YOUR-ANIMATION {
    0% {
        opacity: 0;
    }
    49% {
        opacity: 0;
    }
    50% {
        opacity: 1;
    }
    99% {
        opacity: 1;
    }
    100% {
        opacity: 0;
    }
}
@-webkit-keyframes NAME-YOUR-ANIMATION {
    0% {
        opacity: 0;
    }
    49% {
        opacity: 0;
    }
    50% {
        opacity: 1;
    }
    99% {
        opacity: 1;
    }
    100% {
        opacity: 0;
    }
}
@-moz-keyframes NAME-YOUR-ANIMATION {
    0% {
        opacity: 0;
    }
    49% {
        opacity: 0;
    }
    50% {
        opacity: 1;
    }
    99% {
        opacity: 1;
    }
    100% {
        opacity: 0;
    }
}
@-o-keyframes NAME-YOUR-ANIMATION {
    0% {
        opacity: 0;
    }
    49% {
        opacity: 0;
    }
    50% {
        opacity: 1;
    }
    99% {
        opacity: 1;
    }
    100% {
        opacity: 0;
    }
}
@keyframes NAME-YOUR-ANIMATION {
    0% {
        opacity: 0;
    }
    49% {
        opacity: 0;
    }
    50% {
        opacity: 1;
    }
    99% {
        opacity: 1;
    }
    100% {
        opacity: 0;
    }
}

you'll need to do the same for the other message, the vendor css are important if you want it to work for all browsers. 您需要对其他消息执行相同操作,如果您希望它适用于所有浏览器,则供应商css非常重要。

Sources 来源

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM