Only use the a tag to realize clicking on the navigation bar to jump to the corresponding position on the page

Click the navigation bar to jump to the corresponding position on the page

The a tag is the most convenient way, but there is no sliding or sliding animation, it is directly switched to the specified position

html code:

<body>
	<div>  <!-- 导航栏 -->
		<a href="#first">首页</a>   <!-- href="#" 或者 href="#top" 也可以转到顶部 -->
		<a href="second">第二页</a>
		<a href="third">第三页</a>
	</div>
	
	<!-- 不同页面 -->
	<div id="first">首页</div>
	<div id="second">第二页</div>
	<div id="third">第三页</div>     <!-- <a href="#bot">第三页</a> 也可以转到顶部 -->
</body>

Modify the a tag style css code:

a {
    
    
	text-decoration: none;    /* 去掉下划线 */
	color: white;   /* 去掉默认字体颜色:紫色 */
}

a tag other functions:

mailto: click to send email
insert image description here
tel: click to call
insert image description here

Guess you like

Origin blog.csdn.net/amercury0818/article/details/128418142