gpt4 book ai didi

javascript - 如何在引导模态主体上创建带有固定标题的可滚动表格?

转载 作者:太空狗 更新时间:2023-10-29 15:10:34 26 4
gpt4 key购买 nike

我试过了,但这不起作用。字段值是动态的。所以宽度不是固定的。

<div class="table-responsive">

<table class="table table-hover">
<thead>

<tr>
...

</tr>
</thead>

<tbody style="height:100px;overflow-y:scroll;">
<tr>
...
</tr>
</tbody>
</table>
</div>

最佳答案

HTML

<!-- Large modal -->
<button type="button" class="btn btn-primary" data-toggle="modal" data-target=".bs-example-modal-lg">Large modal</button>

<div class="modal fade bs-example-modal-lg" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<table id="myTable" class="table fix-head table-striped">
<thead>
<tr id="pp">
<th>Column1</th>
<th >Column2</th>
<th >Column3</th>
<th >Column4</th>
<th>Column5</th>
<th>Column6</th>
<th>Column7</th>
<th>Column8</th>
<th>Column9</th>
</tr>
</thead>
<tbody style="height:110px">
<tr>
<td>1</td>
<td>Table cell</td>
<td>Table cell</td>
<td>Table cell</td>
<td>Table cell</td>
<td>Table cell</td>
<td>Table cell</td>
<td>Table cell</td>
<td>Table cell</td>
<td>Table cell</td>
<td>Table cell</td>
<td>Table cell</td>
</tr>
<tr>
<td>2</td>
<td>Table cell</td>
<td>Table cell</td>
<td>Table cell</td>
<td>Table cell</td>
<td>Table cell</td>
<td>Table cell</td>
<td>Table cell</td>
</tr>
<tr>
<td>3</td>
<td>Table cell</td>
<td>Table cell</td>
<td>Table cell</td>
<td>Table cell</td>
<td>Table cell</td>
<td>Table cell</td>
</tr>
<tr>
<td>4</td>
<td>Table cell</td>
<td>Table cell</td>
<td>Table cell</td>
<td>Table cell</td>
<td>Table cell</td>
<td>Table cell</td>
</tr>
<tr>
<td>5</td>
<td>Table cell</td>
<td>Table cell</td>
<td>Table cell</td>
<td>Table cell</td>
<td>Table cell</td>
<td>Table cell</td>
</tr>
<tr>
<td>6</td>

<td>Table cell</td>
<td>Table cell</td>
<td>Table cell</td>
<td>Table cell</td>
<td>Table cell</td>
<td>Table cell</td>
</tr>
<tr>
<td>7</td>
<td>Table cell</td>
<td>Table cell</td>
<td>Table cell</td>
<td>Table cell</td>
<td>Table cell</td>
<td>Table cell</td>
</tr>
<tr>
<td>8</td>
<td>Table cell</td>
<td>Table cell</td>
<td>Table cell</td>
<td>Table cell</td>
<td>Table cell</td>
<td>Table cell</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>

CSS

table.fix-head>tbody, table {
display:block;

}

table.fix-head>tbody {
overflow-y: scroll;
height: 100px;
}
#pp th{

padding-right:28px;
}
#myTable{
width:100%;
}

JS

 $(document).ready(function(){
$('#myModal').on('shown.bs.modal', function () {
$(this).find('.modal-dialog').css({width:'auto',
height:'auto',
'max-height':'100%'});
});
});

在此处检查DEMO:http://codepen.io/ihemant360/pen/vKjNdm

关于javascript - 如何在引导模态主体上创建带有固定标题的可滚动表格?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38538141/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com