Javascript 在页面上加载时从文档向下滑动的文本
我的目标是让问候语滑到页面的“外部”。我最近在这里搜索以供参考,只找到了下面的CuleSeT代码,但它不是我所期待的,因为似乎文本出现在页面的中间…如果有人能帮我,我将不胜感激Javascript 在页面上加载时从文档向下滑动的文本,javascript,jquery,css,jquery-animate,Javascript,Jquery,Css,Jquery Animate,我的目标是让问候语滑到页面的“外部”。我最近在这里搜索以供参考,只找到了下面的CuleSeT代码,但它不是我所期待的,因为似乎文本出现在页面的中间…如果有人能帮我,我将不胜感激 $(文档).ready(函数(){ $(“#问候语”).hide(); $('问候语')。向下滑动(1000); }); #问候语{填充顶部:100px;} 欢迎! 试试看 jQuery: $(document).ready(function(){ // on document ready $("#greeti
$(文档).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
}
这种方法需要使用CSS和jQuery,但希望它能满足需要
当然,您可以将top
属性值更改为所需的任何值,以获得所需的效果
希望有帮助:)太好了!凯兰。这似乎更好后,调整了一点。如果使用jQuery来处理整个事情,我将使用它,但是似乎动画不能很好地使用它。这就是为什么我仍然怀疑的原因。@PattyPutty你似乎面临的问题是什么?