CSS opacity change on div with time delay not user interaction

本小妞迷上赌 提交于 2019-12-06 05:00:51

http://jsfiddle.net/DerekL/9PfMF/

div{
    -webkit-animation: fadein 5s linear 1 normal forwards;
}

@-webkit-keyframes fadein{
    from { opacity: 0; }
    to { opacity: 1; }
}

Have a look at the following example , you need to use keyframes

div {
    background: #333;
    width: 200px;
    height: 200px;
    -webkit-animation: smooth 5s ease-in;
    -moz-animation: smooth 5s ease-in;
    -o-animation: smooth 5s ease-in;
    -ms-animation: smooth 5s ease-in;
    animation: smooth 5s ease-in;
}

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

An example : http://jsfiddle.net/zxx8u/1/

You can use jQuery animate instead, very clean and easy to manipulate.

JSFiddle link

<div style="opacity:0;">some text</div>
$("div").animate({opacity: '1'}, 5000);

You can do with simple css3 keyframe animation

demo

<div class="timedelay"></div>

.timedelay {
  width: 30px;
  height: 30px;
  position: absolute;
  background-color: red;
  -webkit-animation: myanim 5s ease 5s;
}

@-webkit-keyframes myanim {
  0% {
    opacity: 0;
  }

  100% {
    opacity: 1;
  }
}
kamilkrzywda

Something like that works for me:

.chat-messages li{
  -webkit-animation: fadein 5s linear 1 normal forwards;
}

@-webkit-keyframes fadein{
  0% { opacity: 1;}
  90% { opacity: 1;}
  100% { opacity: 0;}
}
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!