App下載

前端開(kāi)發(fā)AmazeUI 平滑滾動(dòng)怎么實(shí)現(xiàn)?效果代碼詳解!

猿友 2021-08-05 11:37:29 瀏覽數(shù) (1798)
反饋

那么對(duì)于:“前端開(kāi)發(fā)AmazeUI 平滑滾動(dòng)怎么實(shí)現(xiàn)?”這個(gè)問(wèn)題,小編在通過(guò)奮斗了一點(diǎn)時(shí)間后,為大家整理的下面的相關(guān)內(nèi)容分享!希望對(duì)大家學(xué)習(xí)有所幫助!

具體代碼如下所示:

<!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>平滑滾動(dòng)</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的寫(xiě)法 -->
<div style="height: 2000px;"></div>
<!-- 滾動(dòng)到頂部 -->
<button data-am-smooth-scroll class="am-btn am-btn-success">滾動(dòng)到頂部</button>
<!-- 滾動(dòng)到底部 -->
<button id="doc-scroll-to-btm" class="am-btn am-btn-primary">滾動(dòng)到底部</button>
<script>
  $('#doc-scroll-to-btm').on('click', function() {
    var $w = $(window);
    $w.smoothScroll({position: $(document).height() - $w.height()});
  });
</script>
<!-- 定義選項(xiàng) -->
<button data-am-smooth-scroll="{position: 57, speed: 5000}" class="am-btn am-btn-danger">慢悠悠地滾到距離頂部 57px 的位置</button>
<!--通過(guò) Data API-->
<!-- 在元素上添加 data-am-smooth-scroll 屬性。 -->
<button data-am-smooth-scroll class="am-btn am-btn-success">滾動(dòng)到頂部</button>
<!-- 如果要指定滾動(dòng)的位置,可以給這個(gè)屬性設(shè)一個(gè)值。 -->
<button data-am-smooth-scroll="{position: 189}" class="am-btn am-btn-secondary">指定滾動(dòng)的位置</button>
<!--
通過(guò) Javascript
$(window).smoothScroll([options]);
// 滾動(dòng)到底部
$('#my-button').on('click', function() {
  var $w = $(window);
  $w.smoothScroll({position: $(document).height() - $w.height()});
});
-->
<div style="height: 2000px;"></div>
</body>
</html> 

效果圖:


 

那么上面的內(nèi)容就是對(duì)于:“前端開(kāi)發(fā)AmazeUI 平滑滾動(dòng)怎么實(shí)現(xiàn)?”這個(gè)問(wèn)題的相關(guān)內(nèi)容,更多與AmazeUI相關(guān)內(nèi)容都可以在W3Cschool中進(jìn)行學(xué)習(xí)和了解! 

0 人點(diǎn)贊