黑松山资源网 Design By www.paidiu.com

具体代码如下所示:

<!doctype html>
<html class="no-js">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="description" content="">
<meta name="keywords" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>平滑滚动</title>
<!--[if (gte IE 9)|!(IE)]><!-->
<script src="assets/js/jquery.min.js"></script>
<!--<![endif]-->
<!--[if lte IE 8 ]>
<script src="assets/ie8/jquery.min.js"></script>
<script src="assets/ie8/modernizr.js"></script>
<script src="assets/js/amazeui.ie8polyfill.min.js"></script>
<![endif]-->
<script src="assets/js/amazeui.min.js"></script>
<link rel="stylesheet" href="assets/css/amazeui.min.css">
</head>
<body style="margin:300px;">
<!-- $('html, body').animate({scrollTop: 0}, '500'); //兼容旧版IE的写法 -->
<div style="height: 2000px;"></div>
<!-- 滚动到顶部 -->
<button data-am-smooth-scroll class="am-btn am-btn-success">滚动到顶部</button>
<!-- 滚动到底部 -->
<button id="doc-scroll-to-btm" class="am-btn am-btn-primary">滚动到底部</button>
<script>
  $('#doc-scroll-to-btm').on('click', function() {
    var $w = $(window);
    $w.smoothScroll({position: $(document).height() - $w.height()});
  });
</script>
<!-- 定义选项 -->
<button data-am-smooth-scroll="{position: 57, speed: 5000}" class="am-btn am-btn-danger">慢悠悠地滚到距离顶部 57px 的位置</button>
<!--通过 Data API-->
<!-- 在元素上添加 data-am-smooth-scroll 属性。 -->
<button data-am-smooth-scroll class="am-btn am-btn-success">滚动到顶部</button>
<!-- 如果要指定滚动的位置,可以给这个属性设一个值。 -->
<button data-am-smooth-scroll="{position: 189}" class="am-btn am-btn-secondary">指定滚动的位置</button>
<!--
通过 Javascript
$(window).smoothScroll([options]);
// 滚动到底部
$('#my-button').on('click', function() {
  var $w = $(window);
  $w.smoothScroll({position: $(document).height() - $w.height()});
});
-->
<div style="height: 2000px;"></div>
</body>
</html>

效果图:

AmazeUI 平滑滚动效果的示例代码
 

黑松山资源网 Design By www.paidiu.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
黑松山资源网 Design By www.paidiu.com