<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
* {
margin: 0;
padding: 0;
}
.container {
display: flex;
position: relative;
z-index: 2;
}
.time {
line-height: 24px;
overflow: auto;
height: 180px;
scroll-snap-type: y mandatory;
}
::-webkit-scrollbar {
display: none;
}
.swap {
display: flex;
height: 180px;
align-items: center;
justify-content: center;
position: relative;
}
.item {
scroll-snap-align: center;
height: 60px;
line-height: 60px;
width: 40px;
text-align: center;
}
.line {
position: absolute;
left: 0;
top: 60px;
width: 100%;
height: 60px;
border-top: 1px solid #000;
border-bottom: 1px solid #000;
z-index: 1;
}
</style>
</head>
<body>
<div class="swap">
<div class="container">
<div class="time">
<div class="item"></div>
<div class="item">01</div>
<div class="item">02</div>
<div class="item">03</div>
<div class="item">04</div>
<div class="item">05</div>
<div class="item">06</div>
<div class="item">07</div>
<div class="item">08</div>
<div class="item">09</div>
<div class="item">10</div>
<div class="item"></div>
</div>
<div class="time">
<div class="item"></div>
<div class="item">01</div>
<div class="item">02</div>
<div class="item">03</div>
<div class="item">04</div>
<div class="item">05</div>
<div class="item">06</div>
<div class="item">07</div>
<div class="item">08</div>
<div class="item">09</div>
<div class="item">10</div>
<div class="item"></div>
</div>
</div>
<div class="line"></div>
</div>
</body>
</html>
了解scroll-snap-type:https://developer.mozilla.org/en-US/docs/Web/CSS/scroll-snap-type