锚点链接是我们在开发中经常会用到的一个技术点,常见的常见有,页面内容过多,而我们不希望拿鼠标一直来回滚动,就需要用到锚点链接,以 " 目录 " 的方式来进行对应的跳转。
而在常见的项目中,锚点链接的使用方法是通过a标签的href属性跳转到某一个元素的id,来找到对应元素的位置,实现效果
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style type="text/css">
*{
margin: 0;
padding: 0;
}
html,body{
width: 100%;
height: 100%;
}
.left{
width: 200px;
height: 100%;
float: left;
border-right: 1px solid black;
}
a{
display: block;
color: #f60;
text-decoration: none;
font-size: 20px;
text-align: center;
margin-bottom: 10px;
}
.right{
width: calc(100% - 201px);
height: 100%;
float: left;
overflow-x: hidden;
overflow-y: auto;
}
</style>
</head>
<body>
<div class="left">
<!-- 锚点的名称 -->
<a href="#box1" >位置一</a>
<a href="#box2" >位置二</a>
</div>
<div cl