<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
.container {
width: 100%;
height: 1500px;
background: gray;
border: 1px solid black;
}
</style>
</head>
<body>
<button id="but">滑动到指定内容区</button>
<div class="container"></div>
<p id="artical">指定内容毒贩夫妇反反复复凤飞飞发发发发发发发发发发发发发发发发</p>
<script>
const but = document.getElementById('but')
but.onclick = () => {
const dom = document.getElementById('artical')
dom.scrollIntoView({ behavior: 'smooth' })
}
</script>
</body>
</html>
通过js滑动到指定内容区
最新推荐文章于 2024-05-03 11:47:20 发布