开发者

HTML - Link to a new section within a page

开发者 https://www.devze.com 2023-03-18 04:48 出处:网络
I am currently using the following code to link to a new location on my document: <ol> <li><a href=\"#1.1\">How to load a file</a></li>

I am currently using the following code to link to a new location on my document:

<ol>
    <li><a href="#1.1">How to load a file</a></li>
</ol>

<h3>
        <a name="1.1">Loading Page</a></h3>

The code is working fine although the link is not bringing the "Loading Page" section to the TOP of the page. Rather, the 'Loading Page' Section of my document is ending up in the middle of m开发者_如何学Goy page. I am not sure how else to explain this, but hopefully someone will understand what it is that I am asking.

Thank you, Evan


Is your "Loading Page" near the bottom of your page? If so, it's possible that your page isn't tall enough, or rather, doesn't have enough content below "Loading Page", to bring the "Loading Page" section to the very top.


Is the scrollbar at the very bottom of the window after clicking on the link? There may not be enough content after "Loading Page" to allow it to appear at the top of the window.


Testing your code in Safari the "Loading page" element IS jumped to, and so the text is rendered at the top. However, I would advise using the id attribute instead of the name attribute for better cross-browser support.


It could be that there is no more room to scroll like @jason or @josh-rosen says. OR if you're just talking about a small amount of space it could be because your H3 has a lot of top margin. I sometimes put empty a tags slightly above the target content.


Change 1.1 to 1_1

Change <a name="1_1"> to <a id="1_1">

(1.1 wont work < HTML5)

0

精彩评论

暂无评论...
验证码 换一张
取 消