【问题标题】:how to keep vertical scroll bar aligned to right side of the page with respect to horizontal scroll bar如何保持垂直滚动条相对于水平滚动条与页面右侧对齐
【发布时间】:2017-03-22 18:16:23
【问题描述】:

在我的网页中,我有一个比我的页面长度大的表格。所以我应用了水平滚动条,我也有垂直滚动条,但问题是它与表格的末尾对齐。因此用户在第一次查看时看不到该滚动条。如果用户水平滚动到表格末尾,那么只有他可以看到垂直滚动。有没有办法让垂直滚动与页面右侧对齐?

【问题讨论】:

  • 请分享您目前已实现的代码,以便更轻松地分析您的问题。或许还贴一张截图。

标签: javascript html css


【解决方案1】:

只需将外部 div 宽度设置为 100% 视口并溢出:自动或滚动

<div>
display something else on page...
</div>
<div style="width:100%;height:150px;overflow:scroll;border:1px solid red">
  <table style="width:1000px;height:500px;table-layout: fixed;">
    <tr>
      <td>a</td>
    </tr>
    <tr>
      <td>b</td>
    </tr>
    <tr>
      <td>c</td>
    </tr>
    <tr>
      <td>d</td>
    </tr>
  </table>
</div>
<div>
display something else on page...
</div>

【讨论】:

    猜你喜欢
    • 2014-09-21
    • 1970-01-01
    • 2012-11-14
    • 1970-01-01
    • 2022-01-01
    • 2013-11-05
    • 1970-01-01
    • 2018-12-23
    • 1970-01-01
    相关资源
    最近更新 更多