Anchor hash to the bottom of the page
What is the universal HTML anchor tag to go to the 'bottom' of the page? I know the tag '#' automatically brings the user to the top of the page but I am not so sure about the bottom of the page though.
There isn't one.
You can simulate it, though, with something like <a id="bottom"></a>
, then linking to #bottom
.
You might find this post helpful, as well.
In my opinion, it's better to implement this in JavaScript and definitely jump to the bottom of the page, instead of relying that the CSS styling on a link makes it always appear at the bottom of the page.
This JavaScript snippet will scroll to the bottom of the document:
document.body.scrollIntoView(false);
Inline JavaScript solution
<a href="javascript: document.body.scrollIntoView(false);">Scroll to bottom</a>
Separate JavaScript solution
HTML
<a href="#" id="scroll-to-bottom">Scroll to bottom</a>
JavaScript
document.getElementById("scroll-to-bottom").addEventListener("click", function () {
document.body.scrollIntoView(false);
});
bung <a name="end"></a>
最后,然后<a href="#end">
作为链接
下一篇: 锚点哈希到页面的底部