Slide down a div on body load

泪湿孤枕 提交于 2019-12-02 05:15:24

Give this fiddle a try: http://jsfiddle.net/ahr3U/

This basically uses CSS3 to set up all the parameters of the transition, (the transition property makes the animation possible) and then just adds the visible class once the document has loaded to trigger the animation.

Here is the code:

HTML:

<div id="notification">Page load complete...</div>

CSS:

#notification {
    background-color: #F00;
    color: #FFF;
    height: 25px;
    position: absolute;
    top: -25px;
    width: 100%;
    transition: top 0.5s;
    -moz-transition: top 0.5s;
    -webkit-transition: top 0.5s;
    -o-transition: top 0.5s;
}

#notification.visible {
    top: 0px;
}

Javascript:

$(document).ready(function(){
    $("#notification").addClass("visible");
});

This suits me better, although it does not slide down, fading in is good enough. http://jsfiddle.net/dqUaX/1/

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!