概述
<!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
最后
以上就是害羞钢笔为你收集整理的纯 CSS 实现 time-picker 效果的全部内容,希望文章能够帮你解决纯 CSS 实现 time-picker 效果所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复