html - CSS 动画不工作

标签 html css css-animations

我有一个简单的 CSS 动画可以在文本中淡入淡出:

#title{
    animation: text 2s;
    -webkit-animation: text 2s;
    -moz-animation: text 2s;
    -o-animation: text 2s;
    font-family: 'Lato300', sans-serif;
    height: 115px;
    position: absolute;
    bottom: -10px;
    left: 0;
    right: 0;
    margin-bottom: auto;
    margin-left: auto;
    margin-right: auto;
    text-align: center;
}

@keyframes text{
    0% {display: none;}
    100% {display: inline;}
}

@-moz-keyframes text{
    0% {display: none;}
    100% {display: inline;}
}

@-webkit-keyframes text{
    0% {display: none;}
    100% {display: inline;}
}

@-o-keyframes text{
        0% {display: none;}
    100% {display: inline;}
}

HTML:

<div id="title"><h1>Text goes here</h1></div>

由于某种原因,动画没有播放。有谁知道为什么? (我保留了所有代码以防其他原因导致问题)

最佳答案

您将无法为 display 属性设置动画。但是,您可以转换 opacity

@-webkit-keyframes text {
    0% {
        opacity: 0;
    }
    100% {
        opacity: 1;
    }
}

http://jsfiddle.net/5FCZA/

关于html - CSS 动画不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15848344/

相关文章:

css - 动画边框效果不适用于 IE

JavaScript scrollTop 问题

javascript - 如何在 JavaScript 中使用查询字符串?

CSS - 如何使 A 链接在带有背景图像的 DIV 中工作

javascript - 下拉菜单无法通过 CSS 或 Javascript 工作?

html - 异常的 CSS3 动画行为

CSS 发光动画关键帧适用于 Chrome 但不适用于 iOS Safari

html - 如何在水平网站中拥有固定的导航栏?

css - 你如何指定一个 :link style in a div class implementation?

php - 外部 CSS 链接无效