我已经创建了一个网站,在开始时有一个闪屏页面,然后我想要滑到屏幕上方,并在按下箭头时消失。我正在尝试使用Jquery中的动画来实现这一点。我已经创建了一个Fiddle供您检查代码。
HTML
<div class='sc'>
<div class='welcome'>
<h1>Welcome to Brownsover Walkers</h1>
</div>
<div class='intro'>
<p>#1 dog walkers in the Brownsover area</p>
</div>
JS
var load = function(){
$('.welcome').hide().fadeIn(2000);
$('.intro').delay(1300).hide().fadeIn(2000);
$('.arrow').delay(3000).hide().fadeIn(2000);
}
var unveil = function(){
$('.arrow').click(function(){
$('.sc').animate({
bottom: '5000px'
}, 500);
});
}
$(document).ready(load,unveil);
CSS
html {
background: url(http://www.brwalkers.esy.es/images/bg3.jpg) no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
background-size: cover;
}
.sc{
position: absolute;
top: 0;
left: 0;
bottom: 0;
width: 100%;
background-color: #e3e3e3;
-webkit-box-shadow: 2px 6px 16px 1px rgba(0,0,0,0.61);
-moz-box-shadow: 2px 6px 16px 1px rgba(0,0,0,0.61);
box-shadow: 2px 6px 16px 1px rgba(0,0,0,0.61);
}
.sc h1{
position: absolute;
text-align: center;
font-size: 70px;
font-family: 'Source Sans Pro', sans-serif;
font-weight: 200;
top: 30%;
bottom: 0;
left: 0;
right: 0;
}
.sc p{
position: absolute;
text-align: center;
font-family: 'Source Sans Pro', sans-serif;
font-weight: 200;
font-size: 25px;
top: 45%;
bottom: 0;
left: 0;
right: 0;
}
.arrow{
position: relative;
}
#arrow1{
cursor: pointer;
position: absolute;
margin: auto;
margin-top: 45%;
top: 0;
left: 0;
right: 0;
bottom: 0;
}
发布于 2016-02-05 06:36:24
我在你的代码中发现了一些错误。
.ready()
传递多个处理程序。您只能传入一个。如果要转到页面顶部,请在html
和body
上调用.animate()
,而不是在.animate()
set scrollTop中调用
https://stackoverflow.com/questions/35212800
复制相似问题