首页 > 解决方案 > 如何使用顶部和底部按钮滚动内容顶部和底部

问题描述

请有人帮忙,如何使用按钮和隐藏的滚动条滚动内容的顶部和底部。在我的示例代码下方。

<!DOCTYPE html>
<html>
<head>

<button onclick="scrollWin(0, 50)">Scroll down</button>

单击其中一个按钮(多次)以滚动文档窗口。

<p>Look at each scrollbar to see the effect.</p>
<p>Click one of the buttons (multiple times) to scroll the document window.</p>
<p>Look at each scrollbar to see the effect.</p>
<button onclick="scrollWin(0, -50)">Scroll up</button><br><br>
<script>
function scrollWin(x, y) {
 window.scrollBy(x, y);
}
</script>
</body>
</html>
<style>

button {

border: 0;

border-radius: 2px;

width: 100%;

background-color: #efefef;

}

.my-custom-scrollbar {

position: relative;

height: 200px;

overflow: auto;

}

</style>

标签: buttonscroll

解决方案


推荐阅读