<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<style>
.outer-container{
position: relative;
overflow: hidden;
width:100%;
height:50px;
}
.inner-container {
/* 重点 */
width:100%;
position: absolute;
left: 0;
overflow-y: hidden;
overflow-x: scroll;
/* 解决ios上不流畅 */
-webkit-overflow-scrolling: touch;
}
.content {
width: 600px;
height: 50px;
}
.item{
display: inline-block;
width:50px;
height:50px;
background:#ddd;
}
/* for Chrome */
.inner-container::-webkit-scrollbar {
display: none;
}
</style>
</head>
<body>
<div class="outer-container">
<div class="inner-container">
<div class="content">
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
</div>
</div>
</div>
</body>
</html>
CSS隐藏滚动栏
最新推荐文章于 2023-08-01 22:53:51 发布