简体   繁体   English

HTML Anchor ID无效

[英]HTML Anchor ID not working

I'm making a quick site and all the content is on one page, and I'm using a small menu with anchor links to make navigating to a certain part faster for the end user. 我正在制作一个快速网站,所有内容都在一个页面上,我正在使用带有锚链接的小菜单,以便为最终用户更快地导航到某个部分。 I have two anchor links that work fine (About Me, My Projects) but the "Contact Me" link jumps to a random part of the "My Projects" section. 我有两个工作正常的锚链接(关于我,我的项目)但“联系我”链接跳转到“我的项目”部分的随机部分。

A preview of the site is available here : http://dev.cuonic.com/cuonic.com/ 该网站的预览可在此处获得: http//dev.cuonic.com/cuonic.com/

I have checked the IDs, they correspond, there is no random "contact-me" ID lying around in the "My Projects" section, I've changed the ID, still happens, and this in both Firefox and Chrome. 我已经检查了ID,他们对应,“我的项目”部分中没有随机的“联系我”ID,我已经更改了ID,仍然会发生这种情况,这在Firefox和Chrome中都有。 Whats going on ? 这是怎么回事 ? Any help is appreciated :) 任何帮助表示赞赏:)

All of then content within //*[@id="content"]/div[2] is floated to the left. 然后//*[@id="content"]/div[2]都浮动到左侧。 Floating elements don't affect the height of their containing block-level elements. 浮动元素不会影响其包含块级元素的高度。 If you add this: 如果你添加这个:

#contact-me { clear:both; }

to your CSS somewhere, the <span id="contact-me"> tag will reposition to where you actually want it. 对于你的CSS, <span id="contact-me">标签将重新定位到你真正想要的地方。 Your page still isn't long enough for the contact form to go all the way to the top (at least on my monitor), but it will still scroll to the end of the page. 您的页面仍然不够长,联系表单一直到顶部(至少在我的显示器上),但它仍然会滚动到页面的末尾。

Change this section of code: 更改此部分代码:

</div>
<span class="anchor" id="contact-me"></span>
<h1>Contact Me</h1>
<div class="text">

To this: 对此:

</div>
<h1>Contact Me</h1>
<span class="anchor" id="contact-me"></span>
<div class="text">

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM