gpt4 book ai didi

html - 在 Angular 中滚动浏览器页面时修复表格 thead

转载 作者:行者123 更新时间:2023-11-28 02:26:41 25 4
gpt4 key购买 nike

我想在 table thead 到达首页时以 Angular 修复它。当我在表格内滚动时,滚动 thead 是固定的,这种情况我使用粘性但当我滚动浏览器页面时它不起作用。下面是我想要的图片

enter image description here

在 HTML 中

 <div class="table-responsive " style="width: 100%; height: 670px;">
<!--<table class="table table-striped table-bordered">-->
<table class="table table-hover info">
<thead>
<tr style="background-color: lightskyblue;">
<th>ID</th>
<!--<th jhiTranslate="jhiApp.kassa.date_enter">DateEnter</th>-->
<th jhiTranslate="jhiApp.kassa.date_prov">DateProv</th>
<th jhiTranslate="jhiApp.kassa.date_doc">DateDoc</th>
<th jhiTranslate="jhiApp.kassa.num_doc">NumDoc</th>
<th jhiTranslate="jhiApp.kassa.acc_db">AccDb</th>
<th jhiTranslate="jhiApp.kassa.bank_db">BankDb</th>
<th jhiTranslate="jhiApp.kassa.name_db">NameDb</th>
<th jhiTranslate="jhiApp.kassa.acc_cr">AccCr</th>
<th jhiTranslate="jhiApp.kassa.bank_cr">BankCr</th>
<th jhiTranslate="jhiApp.kassa.name_cr">NameCr</th>
<th jhiTranslate="jhiApp.kassa.currency">Currency</th>
<th jhiTranslate="jhiApp.kassa.summa">Summa</th>
<th jhiTranslate="jhiApp.kassa.summa_eq">SummaEq</th>
<th jhiTranslate="jhiApp.kassa.purpose">Purpose</th>
<th jhiTranslate="jhiApp.kassa.inn_db">InnDb</th>
<th jhiTranslate="jhiApp.kassa.inn_cr">InnCr</th>
</tr>
</thead>
<tbody *ngFor="let array of kassas">

</tbody>
</table>
</div>

在 CSS 中

thead th {
position: sticky;
top: 0;
background-color: lightskyblue;

最佳答案

也许这段代码有用

thead th{
background-color: lightskyblue;
}

thead {
position: sticky;
top: 0;
}

.table-responsive {
max-height: 400px;
overflow: auto;
position: sticky;
top: 0;
background-color: #fff;
}
 <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
<h1>Table</h1>
<div class="table-responsive " style="width: 100%; height: 670px;">
<!--<table class="table table-striped table-bordered">-->
<table class="table table-hover info">
<thead>
<tr>
<th>ID</th>
<!--<th jhiTranslate="jhiApp.kassa.date_enter">DateEnter</th>-->
<th jhiTranslate="jhiApp.kassa.date_prov">DateProv</th>
<th jhiTranslate="jhiApp.kassa.date_doc">DateDoc</th>
<th jhiTranslate="jhiApp.kassa.num_doc">NumDoc</th>
<th jhiTranslate="jhiApp.kassa.acc_db">AccDb</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
<td>5</td>
</tr>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
<td>5</td>
</tr>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
<td>5</td>
</tr>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
<td>5</td>
</tr>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
<td>5</td>
</tr>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
<td>5</td>
</tr>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
<td>5</td>
</tr>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
<td>5</td>
</tr>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
<td>5</td>
</tr>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
<td>5</td>
</tr>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
<td>5</td>
</tr>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
<td>5</td>
</tr>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
<td>5</td>
</tr>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
<td>5</td>
</tr>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
<td>5</td>
</tr>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
<td>5</td>
</tr>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
<td>5</td>
</tr>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
<td>5</td>
</tr>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
<td>5</td>
</tr>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
<td>5</td>
</tr>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
<td>5</td>
</tr>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
<td>5</td>
</tr>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
<td>5</td>
</tr>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
<td>5</td>
</tr>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
<td>5</td>
</tr>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
<td>5</td>
</tr>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
<td>5</td>
</tr>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
<td>5</td>
</tr>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
<td>5</td>
</tr>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
<td>5</td>
</tr>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
<td>5</td>
</tr>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
<td>5</td>
</tr>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
<td>5</td>
</tr>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
<td>5</td>
</tr>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
<td>5</td>
</tr>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
<td>5</td>
</tr>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
<td>5</td>
</tr>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
<td>5</td>
</tr>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
<td>5</td>
</tr>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
<td>5</td>
</tr>

</tbody>
</table>
</div>
<p>lorem</p>
<p>lorem</p>
<p>lorem</p>
<p>lorem</p>
<p>lorem</p>
<p>lorem</p>
<p>lorem</p>
<p>lorem</p>
<p>lorem</p>
<p>lorem</p>
<p>lorem</p>
<p>lorem</p>
<p>lorem</p>
<p>lorem</p>
<p>lorem</p>
<p>lorem</p>
<p>lorem</p>
<p>lorem</p>
<p>lorem</p>
<p>lorem</p>
<p>lorem</p>
<p>lorem</p>
<p>lorem</p>
<p>lorem</p>
<p>lorem</p>
<p>lorem</p>
<p>lorem</p>
<p>lorem</p>
<p>lorem</p>
<p>lorem</p>
<p>lorem</p>
<p>lorem</p>
<p>lorem</p>
<p>lorem</p>
<p>lorem</p>
<p>lorem</p>
<p>lorem</p>
<p>lorem</p>
<p>lorem</p>
<p>lorem</p>

关于html - 在 Angular 中滚动浏览器页面时修复表格 thead,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53555464/

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