从屏幕右下角滑动的“返回顶部”按钮

时间:2015-08-21 12:20:17

标签: javascript jquery

我一直在尝试在网页上集成自定义返回顶部按钮,但我无法使用JQuery移动(滑动)它。我想要的是当页面滚动达到特定数量时从屏幕的不可见部分向右滑动按钮,并在滚动量小于指定时从左向右滑动(到屏幕的不可见部分)

任何建议或代码片段都会很有价值!

以下是代码:

自定义css:



 <ion-nav-view name="managerContent"></ion-nav-view>
&#13;
&#13;
&#13;

这是jquery

&#13;
&#13;
a.custom-back-to-top {
	width: 80px;
	height: 40px;
	color: white;
	text-align: center;
	vertical-align: middle;
	font-weight: bold;
	white-space: nowrap;
	position: fixed;
	z-index: 9999;
	right: -100px;
	bottom: 20px;
	background: #444;
}
&#13;
&#13;
&#13;

1 个答案:

答案 0 :(得分:0)

$(window).scroll(function () {
    var button_threshold = someNumber;

    if ($(window). scrollTop > button_threshold) {
        // Move button into view
    } else {
        // Move button out of view
    }
});
相关问题