【问题标题】:overflow is not working in this code溢出在此代码中不起作用
【发布时间】:2014-06-03 18:39:45
【问题描述】:

我有一个包含项目的表。这些项目在x axis 中。我想通过在该表上添加一个水平滚动来处理溢出。

这是我的css

.agent-table-wrap {
    margin:0;
    padding:2px;
    /*margin-top:5px;*/
    margin-bottom:10px;
    margin-left:4%;
    font: 14px Arial,Helvetica,sans-serif;
    color:#747474;
    display: inline-block;
    padding-top:0px;
    /*background-color:#0c2a62;*/
    overflow:auto;
}

这是我的html:

<div class="thirdDiv">
                 <div class="slNewClass">
                     <div class="details">
                         <span class="content">Service Level</span>
                         <span class="value" id="slSpan" runat="server">0%</span>
                     </div>
                 </div>
                 <div class="agent-table-wrap">
                     <table id="agentsTable" runat="server">
                         <tr class="psdg-top" id="agentsNames">
                             <td class="title">Agent Name</td>
                         </tr>
                         <tr class="psdg-middle" id="agentsStatuses">
                             <td class="title">Agent Status</td>
                         </tr>
                     </table>
                 </div>
             </div>

但卷轴会出现在所有页面上,不仅仅是在桌子上

请检查:

溢出前:

溢出后:

【问题讨论】:

  • 添加widthmax-width 使overflow 生效。

标签: html css


【解决方案1】:

您需要设置一个宽度,否则它将采用100% 的宽度。此外,您可能希望指定 overflow-x: scroll; 仅应用水平滚动。

.slNewClass {
   width: 15%;
}

.agent-table-wrap {
    width: 80%;
    margin:0;
    padding:2px;
    /*margin-top:5px;*/
    margin-bottom:10px;
    margin-left:4%;
    font: 14px Arial,Helvetica,sans-serif;
    color:#747474;
    display: inline-block;
    padding-top:0px;
    /*background-color:#0c2a62;*/
    overflow-x: scroll;
}

【讨论】:

  • 这很好用。 +1。一旦系统允许,将接受答案
【解决方案2】:

这就是你要找的东西

Fiddle

 .thirdDiv{max-height:200px; overflow:auto}

【讨论】:

  • 您的解决方案对我没有帮助。我的问题不在thirdDiv 上,而是在里面的表格上。
  • +1 感谢您与我的努力。他们另一个人帮助了我
猜你喜欢
  • 2020-06-27
  • 2016-04-06
  • 2014-02-01
  • 2017-01-09
  • 2018-04-01
  • 2013-01-10
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多