如何仅使用CSS和HTML制作从顶部到顶部的按钮? [英] How to make a back-to-top button using CSS and HTML only?
问题描述
我正在尝试做的事情有点像back to top
按钮,但是要向下滚动并向上滚动到页面上的某个点!假设您的文本较长,并且您想通过仅单击链接就将用户带到下一个段落...我过去已经做过,但是我不记得自己是怎么做的我的生活...
What i'm trying to do is kind of like a back to top
button but to scroll down and up to a certain point on the page! Say for instance you have a long text and you want to bring the user to the next paragraph by simply having him to click on a link... I've done it in the past but I can't remember how I did it for the life of me...
推荐答案
您想要做的是使用<a>
标签在页面顶部放置一个"anchor"(对于链接而言,这并不是很有用! ).然后,当您有一个链接到#nameofanchor
时,它将滚动到具有该名称的锚点.您可以这样:
What you would want to do is put an "anchor" at the top of the page, using an <a>
tag (it's not JUST useful for links!). Then, when you have a link that goes to #nameofanchor
, it scrolls to the anchor with that name. You'd do it like this:
<a name="top"></a>
<!--content here-->
<a href="#top">Back to top</a>
这是一个有效的jsfiddle: http://jsfiddle.net/qf0m9arp/1/
Here is a working jsfiddle: http://jsfiddle.net/qf0m9arp/1/
这篇关于如何仅使用CSS和HTML制作从顶部到顶部的按钮?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!