pul*_*kit 3 html css jquery jquery-plugins parallax
嘿伙计们,我想在我的网站上制作动画效果,当我们点击菜单链接(比如说,关于部分)时,它会以视差风格动画到该div.
那么大家,如果你知道任何jquery插件可以帮助我在这种情况下,那么请让我知道,如果你也向我展示一个例子会更好.
请参阅代码以获取帮助:
.Home-section {
height: 500px;
background: deepskyblue;
}
.About-section {
height: 300px;
background: deeppink;
}Run Code Online (Sandbox Code Playgroud)
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.0.2/jquery.min.js"></script>
<a href="#">Home</a>
<a href="#">About</a>
<div class="Home-section">
<h1> Hello </h1>
</div>
<div class="About-section">
<h1>Bye</h1>
</div>Run Code Online (Sandbox Code Playgroud)
因此,根据我想要动画到关于部分的代码,点击链接说明关于
希望你想要这个.谢谢
// handle links with @href started with '#' only
$(document).on('click', 'a[href^="#"]', function(e) {
// target element id
var id = $(this).attr('href');
// target element
var $id = $(id);
if ($id.length === 0) {
return;
}
// prevent standard hash navigation (avoid blinking in IE)
e.preventDefault();
// top position relative to the document
var pos = $(id).offset().top - 10;
// animated top scrolling
$('body, html').animate({scrollTop: pos});
});Run Code Online (Sandbox Code Playgroud)
.Home-section {
height:500px;
background: deepskyblue;
}
.About-section {
height:300px;
background:deeppink;
}Run Code Online (Sandbox Code Playgroud)
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<a href="#home">Home</a>
<a href="#about">About</a>
<div class="Home-section" id="home"><h1> Hello </h1>
</div>
<div class="About-section" id="about"><h1>Bye</h1>
</div>Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
209 次 |
| 最近记录: |