javascript - CSS 动画淡入效果似乎不起作用

标签 javascript html css jquery-mobile cordova

我试图在我的网页上应用对我网页内容的淡入淡出效果,但我的内容只是“隐藏”而不是使淡入淡出效果。

这是我正在使用的 CSS:

/* make keyframes that tell the start state and the end state of our object */
@-webkit-keyframes fadeIn { from { opacity:0 !important; } to { opacity:1 !important; } }
@-moz-keyframes fadeIn { from { opacity:0 !important;  } to { opacity:1 !important; } }
@keyframes fadeIn { from { opacity:0 !important; } to { opacity:1 !important; } }


fadeIn

.fade-in {
    opacity:0;  /* make things invisible upon start */
    -webkit-animation:fadeIn ease-in 1 ;  /* call our keyframe named fadeIn, use animattion ease-in and repeat it only 1 time */
    -moz-animation:fadeIn ease-in 1 ;
    animation:fadeIn ease-in 1;

    -webkit-animation-fill-mode:forwards;  /* this makes sure that after animation is done we remain at the last keyframe value (opacity: 1)*/
    -moz-animation-fill-mode:forwards;
    animation-fill-mode:forwards;

    -webkit-animation-duration:1s ;
    -moz-animation-duration:1s ;
    animation-duration:1s ;
}

.fade-in.one {
    -webkit-animation-delay: 0.7s ;
    -moz-animation-delay: 0.7s ;
    animation-delay: 0.7s;
}

对于这段html:

<div data-role="content" id="contenidoHistoria" class="fade-in one">

        <p>Entre los melismas sonoros del rebalaje y las intrincadas calles del antiguo barrio del Perchel, y a la sombra espiritual de su Iglesia parroquial del Carmen, surgi&oacute en el a&ntilde;o 2005 el sue&ntilde;o colectivo de un grupo de j&oacutevenes de aquel barrio, que bajo el &aacutenimo y el empuje del entonces p&aacuterroco nuestro querido Manolo Segura- se propusieron poner en marcha la hoy conocida como Banda de Cornetas y Tambores de Nuestra Se&ntilde;ora del Carmen del Perchel-M&aacutelaga.</p>

    </div><!-- /content -->
</div>

如果我在“.fade-in { 上将不透明度设置为 NOT 0 不透明度:0;/* 让事情在开始时不可见 */"我可以看到内容,但当然这不是我要找的。

问候。

最佳答案

从您的动画属性中删除 !important。 (同时删除关键帧声明下方的“淡入”。)

这是一个工作版本:

http://jsfiddle.net/x62pU/2/

我还编辑了动画声明的简写以减少您的代码。

关于javascript - CSS 动画淡入效果似乎不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24774720/

相关文章:

javascript - Angular 动态访问对象属性

javascript - Chrome Google 帐户注销或 Google 帐户用户切换事件

javascript - 将这些时间参数转换为纪元时间

javascript - ESLint 定义前不使用

java - 下拉框在 JSP 中不起作用

javascript - 当在网站的不同 div 上滚动时,使 Bootstrap4 导航栏改变颜色

html - 使用左右 CSS 属性绝对定位 INPUT 时的奇怪行为

html - <a name> 导致内容上推

css - 使用文本链接而不是输入上传文件

html - <body> 在我将样式添加到 Bootstrap nav { position :fixed } 时下降