javascript - Jquery 附加超出最大高度

标签 javascript jquery html css

我有一个jquery代码,它循环遍历对象列表并将html附加到表中。但是我已经设置了父/表的最大高度。表行仍然超出父级。

记录应该停在图中的红线处,并且应该出现滚动条。

有人可以帮忙吗?

Jquery

$.each(data, function (i, item) {
     $('#dataTable').append("<tr><td>" + i + '</td><td>' + item.name+ '</td><td>' + item.English + '</td><td>' + item.Quantity + '</td><td>' + item.Brand + '</td></tr>')
});

HTML

<div class="panel panel-default" style="height:700px;">
   <div class="panel-heading">Records</div>
   <div class="panel-body" style="max-height:700px; z-index:5;">
      <table id="dataTable" class="table" style="height:700px;overflow:auto;">
         <tr>
            <th>S/N</th>
            <th>name</th>
            <th>Description</th>
            <th>Qty</th>
            <th>Brand</th>
         </tr>
      </table>
   </div>
</div>

enter image description here

最佳答案

从表格标记 height:700px;overflow:auto; 中删除以下样式案例,并在类 .panel- 中应用 overflow:auto; 样式案例正文overflow:auto; 样式大小写在表格标记中不起作用。

关于javascript - Jquery 附加超出最大高度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44017389/

相关文章:

Javascript join(),我想将其中一些加入数组中

javascript - 如何根据浏览器大小让内容适合整个屏幕?

php - 如何从 http 更改为 https?

javascript - 单击 Accordion 图像后保持 DIV 事件

javascript - ng-repeat 在 html 中显示数组中对象的索引

javascript - 另一个关于如何删除版本 2 中的 A 和 B 图标的 Google map 问题。*

javascript - C3折线图: compress or break interval between distant points

jquery - Highcharts 异步钻取

jQuery、CSS、-webkit-transform : NO animation

javascript - 为每个添加的元素增加 div 的高度