Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/381.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 在页面上加载时从文档向下滑动的文本_Javascript_Jquery_Css_Jquery Animate - Fatal编程技术网

Javascript 在页面上加载时从文档向下滑动的文本

Javascript 在页面上加载时从文档向下滑动的文本,javascript,jquery,css,jquery-animate,Javascript,Jquery,Css,Jquery Animate,我的目标是让问候语滑到页面的“外部”。我最近在这里搜索以供参考,只找到了下面的CuleSeT代码,但它不是我所期待的,因为似乎文本出现在页面的中间…如果有人能帮我,我将不胜感激 $(文档).ready(函数(){ $(“#问候语”).hide(); $('问候语')。向下滑动(1000); }); #问候语{填充顶部:100px;} 欢迎! 试试看 jQuery: $(document).ready(function(){ // on document ready $("#greeti

我的目标是让问候语滑到页面的“外部”。我最近在这里搜索以供参考,只找到了下面的CuleSeT代码,但它不是我所期待的,因为似乎文本出现在页面的中间…如果有人能帮我,我将不胜感激

$(文档).ready(函数(){
$(“#问候语”).hide();
$('问候语')。向下滑动(1000);
});
#问候语{填充顶部:100px;}
欢迎!
试试看

jQuery

$(document).ready(function(){ // on document ready
    $("#greeting").addClass("active"); // add the class "active" to the greeting text
});
#greeting{
    position: fixed; 
    top: -200px; // start at 200px above the page
    transition: top 500ms; // take 0.5s to move from -200px to 500px
} 
#greeting.active{ // when #greeting has class "active"
    top: 500px; // move to 500px from the top of the page
}
CSS

$(document).ready(function(){ // on document ready
    $("#greeting").addClass("active"); // add the class "active" to the greeting text
});
#greeting{
    position: fixed; 
    top: -200px; // start at 200px above the page
    transition: top 500ms; // take 0.5s to move from -200px to 500px
} 
#greeting.active{ // when #greeting has class "active"
    top: 500px; // move to 500px from the top of the page
}
这种方法需要使用CSSjQuery,但希望它能满足需要

当然,您可以将
top
属性值更改为所需的任何值,以获得所需的效果


希望有帮助:)

太好了!凯兰。这似乎更好后,调整了一点。如果使用jQuery来处理整个事情,我将使用它,但是似乎动画不能很好地使用它。这就是为什么我仍然怀疑的原因。@PattyPutty你似乎面临的问题是什么?