CSS实现滚动条隐藏

  1. 使用伪元素:::-webkit-scrollbar
<!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>
    <style>
      * {
        margin: 0;
        padding: 0;
      }
      .content {
        width: 200px;
        height: 100px;
        background-color: pink;
        overflow-y: scroll;
        margin: 20px auto;
        text-align: center;
      }
      .content::-webkit-scrollbar {
        display: none;
      }
    </style>
  </head>
  <body>
    <div class="content">
      <p>1</p>
      <p>2</p>
      <p>3</p>
      <p>4</p>
      <p>5</p>
      <p>6</p>
      <p>7</p>
      <p>8</p>
      <p>9</p>
      <p>10</p>
    </div>
  </body>
</html>
posted @ 2023-10-14 03:50  Morita-desin  阅读(52)  评论(0)    收藏  举报