*(一)前言
基于大部分场景,我们需要使用横向滚动,这种时候,大部分会选择swiper来实现,但是其实,我们也可以通过纯CSS的方式实现一个滚动条
*(二)实现
大家都知道overflow 可以单独设置
// 横向滚动
overflow-x: scroll;
// 纵向滚动
overflow-y: scroll;
基于上面知识,我们首先来实现一个滚动,
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta
name="viewport"
content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no"
/>
<title>滚动条</title>
<style>
* {
padding: 0;
margin: 0;
box-sizing: border-box;
}
html, body {
height: 100%;
}
body {
display: flex;
flex-direction: column;
justify-content: center;
}
.container {
width: 100%;
height: 200px;
border: