结构
<body>
<div class="container">
<div class="goods">
<div class="box1" id="box1">服饰</div>
<div class="box2" id="box2">家电</div>
<div class="box3" id="box3">生鲜</div>
</div>
<div class="slidebar">
<a href="#box1">服饰</a>
<a href="#box2">家电</a>
<a href="#box3">生鲜</a>
</div>
</div>
</body>
css
<style>
.container {
width: 100%;
height: 3000px;
display: grid;
grid-template-rows: 1fr;
grid-template-columns: 1fr 150px;
grid-row: 1 / span 6;
grid-column: 2 / span 3;
}
.container .goods {
display: grid;
grid-row-gap: 600px;
}
.container .goods div {
background-color: green;
}
.container .goods div:nth-child(2) {
background-color: red;
}
.container .slidebar {
position: sticky;
left: 0;
top: 500px;
margin: auto;
}
.container .slidebar a {
text-decoration: none;
display: block;
width: 100px;
height: 100px;
background-color: pink;
line-height: 100px;
text-align: center;
}
.container .slidebar a:nth-child(2) {
background-color: yellowgreen;
}
</style>
使用a链接的href锚点,使用grid栅格布局,使用sticky电梯导航的粘性布局
实现简单的电梯导航