代码之家  ›  专栏  ›  技术社区  ›  Rohit Verma

如何在HTML中从底部删除溢出滚动条边框

  •  -2
  • Rohit Verma  · 技术社区  · 7 年前

    我有一个带有溢出滚动的引导表(.table responsive)。它工作正常,但我想从底部删除滚动条。我怎样才能取下它?

    <!DOCTYPE html>
    <html lang="en">
    <head>
      <title>Bootstrap Example</title>
      <meta charset="utf-8">
      <meta name="viewport" content="width=device-width, initial-scale=1">
      <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css">
      <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
      <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js"></script>
      <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"></script>
    </head>
    <body>
    
    <div class="container">
      <div class="table-responsive">
      <table class="table table-bordered" style="width:1500px;">
        <thead>
          <tr>
            <th>Firstname</th>
            <th>Lastname</th>
            <th>Email</th>
          </tr>
        </thead>
        <tbody>
          <tr>
            <td>John</td>
            <td>Doe</td>
            <td>john@example.com</td>
          </tr>
          <tr>
            <td>Mary</td>
            <td>Moe</td>
            <td>mary@example.com</td>
          </tr>
          <tr>
            <td>July</td>
            <td>Dooley</td>
            <td>july@example.com</td>
          </tr>
        </tbody>
      </table>
    </div>
    </div>
    
    <script>
    
    </script>
    
    </body>
    </html>
    1 回复  |  直到 7 年前
        1
  •  3
  •   Patrik Alexits    7 年前

    是因为你的桌子比它的容器宽吗?要么你 用1500px删除内联样式 或给予 overflow-x: hidden; 到将禁用水平滚动的容器,但表的宽度将相同,其中很大一部分将不可见。

    如果要保持水平滚动,但要隐藏滚动条,则应尝试以下操作:

    div::-webkit-scrollbar{
      display: none;
    }
    

    注意:它只在基于WebKit的浏览器中工作