如何使用顶部和底部按钮滚动内容的顶部和底部

时间:2020-02-22 02:03:21

标签: button scroll

请帮助一下如何使用按钮和隐藏的滚动条上下滚动内容。在我的示例代码下面。

<!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>

0 个答案:

没有答案
相关问题