PHP数据表的隐藏溢出

时间:2012-09-11 02:22:19

标签: php html css html-table overflow

我有一个像这样的重复数据表(我知道在这种情况下php部分远非正确,但这不是问题):

<table style="overflow:scroll" id="displayTable">
   <tr>
      <td>
      <table id="DataTable">
          <? php repeat>
            <tr>
             <td><? php echo $rowData['Column Name'];></td>
            </tr>
          <? php end repeat>
      </table>
      </td>
    </tr>
</table>

我正在寻找一种方法来使表格上的溢出可滚动。我已尝试过如上所示的<div style="overflow:scroll"></div>,但这不起作用。我想要它,以便'DataTable'表的整体高度可以在它所在的'displayTable'的表格单元格中滚动。

1 个答案:

答案 0 :(得分:0)

只需使用固定高度的overflow:scrolloverflow:auto元素包裹您的表格。

<强>标记

<div class="wrapper">
    <table>
        <tbody>
            <tr>
                <td>A Cell</td>
                <td>A Cell</td>
                <td>A Cell</td>
            </tr>  
            <tr>
                <td>A Cell</td>
                <td>A Cell</td>
                <td>A Cell</td>
            </tr>         
        </tbody>
    </table>       
</div>

<强>风格

.wrapper{
    height:200px;
    overflow:auto;
}

Da live fiddler