css自定义可隐藏滚动条
<!DOCTYPE html>
<html lang="en">
<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>
</head>
<body>
<ul>
<li>12</li>
<li>2</li>
<li>3</li>
<li>4</li>
<li>5</li>
<li>6</li>
<li>7</li>
<li>8</li>
<li>9</li>
<li>10</li>
<li>11</li>
<li>12</li>
<li>13</li>
<li>14</li>
<li>15</li>
<li>16</li>
<li>17</li>
<li>18</li>
<li>19</li>
<li>20</li>
</ul>
<style>
* {
margin: 0;
padding: 0;
}
html,
body {
width: 100%;
height: 100%;
}
ul {
-webkit-transition: all .5s;
width: 200px;
height: 300px;
margin: 30px auto;
list-style: none;
overflow-y: scroll;
}
li {
width: 100%;
height: 30px;
border-bottom: 1px solid #aaa;
}
li:hover {
background: #eee;
}
ul.hide {
color: transparent!important;
}
*::-webkit-scrollbar {
/*滚动条整体样式*/
width: 0;
/*高宽分别对应横竖滚动条的尺寸*/
height: 1px;
}
*:hover::-webkit-scrollbar {
width: 10px;
}
*::-webkit-scrollbar-thumb {
border-radius: 5px;
box-shadow: inset 0 0 0 5px;
/* 用box-shadow模拟滚动条 */
}
*::-webkit-scrollbar-track {
/*滚动条里面轨道*/
-webkit-box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.2);
border-radius: 10px;
background: #EDEDED;
}
</style>
</body>
</html>