如何在同一HTML页面中创建从一个部分到另一个部分的链接 [英] How to create links from one section to another section in same HTML page

查看:135
本文介绍了如何在同一HTML页面中创建从一个部分到另一个部分的链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在同一页面中创建从一个部分到另一个部分的链接。



当我点击任何项目(伦敦)时,我有一个部分(NAV)链接应显示在部分页面内。



现在它只是重定向到另一个页面。



如何我可以在同一页面制作。



根据回复更新编码后,它也无效。该链接转到另一页



参考下面的代码



<!DOCTYPE html>



< html>

< head>

< style>



#nav {

行高:30px;

背景颜色:粉红色;

身高:300px;

宽度:100px;

float:left;

padding:5px;

}

#section {

宽度:350px;

float:left;

padding:10px;

}

< / style>

< / head>

< ; / body>













超链接去这里





< / body>

< / html>

解决方案

 <   p  >  
< a href = #section > 伦敦< / a >
< / p >

< div >
< a name = section > < / a >
超链接到这里
< ; / div >


它转到另一个页面,因为您的代码中的链接是www.google.com/#section

它应该只是#section



解决方案1是正确的。


I want to create links from one section to another section in same page.

Here I have one section ( NAV) when I click any item ( London) the link should display inside the section page.

Now it just redirect to another page.

How can I make in same page.

After updating the coding based on reply it also did not work. the link goes to another page

Refer below code

<!DOCTYPE html>

<html>
<head>
<style>

#nav {
line-height:30px;
background-color: pink;
height:300px;
width:100px;
float: left;
padding:5px;
}
#section {
width:350px;
float: left;
padding:10px;
}
</style>
</head>
</body>






Hyperlink goes here



</body>
</html>

解决方案

<p>
    <a href="#section">London</a>
</p>

<div>
    <a name="section"></a>
    Hyperlink goes here
</div>


It goes to another page because the link in your code is "www.google.com/#section".
It should be just "#section".

Solution 1 is correct.


这篇关于如何在同一HTML页面中创建从一个部分到另一个部分的链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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