如何在页面加载时隐藏一个 div,然后在页面加载后向下滑动?我不想使用 CSS display:none;
最佳答案
试试这个 fiddle :http://jsfiddle.net/ahr3U/
这基本上使用 CSS3 来设置过渡的所有参数(过渡属性使动画成为可能),然后在文档加载后添加可见类以触发动画。
代码如下:
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");
});
关于javascript - 在 body 负荷上向下滑动一个 div,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8550009/