使用html滚动到特定元素 [英] Scroll to a specific Element Using html

查看:406
本文介绍了使用html滚动到特定元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

html中是否有一种方法可以使页面使用HTML滚动到特定元素!?

Is there a method in html which makes the webpage scroll to a specific Element using HTML !?

推荐答案

是的,您使用此

<a href="#google"></a>

<div id="google"></div>

但是,这并不能创建平滑的滚动.

But this does not create a smooth scroll just so you know.

您还可以添加CSS

html {
  scroll-behavior: smooth;
}

这篇关于使用html滚动到特定元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆