如何导航到页面的一部分 [英] How to navigate to a section of a page

查看:90
本文介绍了如何导航到页面的一部分的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含链接的目标网页。
如何将用户导向不同页面的某个部分?



主页:

 < a href =/ sample>寿司< / a> 
< a href =/ sample> BBQ< / a>

示例页面:

 < div id ='sushi'>< / div> 
< div id ='bbq'>< / div>

在主页面点击寿司或烧烤应该将用户导航到div sushi bbq (分别)页面样本

没有JQuery可能吗?
我不介意使用JQuery,但使用html的更简单的解决方案也可以。

使用HTML的锚点



Main

 < a href =sample.html#sushi>寿司< / a> 
< a href =sample.html#bbq> BBQ< / a>

示例页面:

 < div id ='sushi'>< a name ='sushi'>< / a>< / div> 
< div id ='bbq'>< a name ='bbq'>< / a>< / div>


I have a landing page with links. How can I direct user to a section of a different page?

Main Page:

<a href="/sample">Sushi</a>
<a href="/sample">BBQ</a>

Sample Page:

<div id='sushi'></div>
<div id='bbq'></div>

Clicking on "Sushi" or "BBQ" in the Main Page should navigate the user to the div with id sushi or bbq (respectively) of the page sample.

Is it possible without JQuery? I do not mind using JQuery but a simpler solution using html would work too.

解决方案

Use HTML's anchors:

Main Page:

<a href="sample.html#sushi">Sushi</a>
<a href="sample.html#bbq">BBQ</a>

Sample Page:

<div id='sushi'><a name='sushi'></a></div>
<div id='bbq'><a name='bbq'></a></div>

这篇关于如何导航到页面的一部分的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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