[英]Why the height of my first row is more than other rows HTML
I'm wondering why the height of first row March 2020
of first product Jiko Supa Eco
is larger than other rows, even though I have fixed it too.我想知道为什么
March 2020
第一个产品Jiko Supa Eco
的第一行的高度比其他行大,即使我也修复了它。 ? ? Before posting the question, I check in developer tools for any blank data, which might be causing the problem, but that's not the case.
在发布问题之前,我检查了开发人员工具中是否存在任何可能导致问题的空白数据,但事实并非如此。 Thanks to those helping hands
感谢那些伸出援手的人
Here is my HTML code这是我的 HTML 代码
<table>
<thead class="loanProductsHeader">
<tr>
<td>Installment Month</td>
<td>Due Date</td>
<td>Installment Amount</td>
<td>Amount Received</td>
<td>Payment Date</td>
<td>Mpesa Code</td>
</tr>
</thead>
<tbody *ngFor="let loanInstallments of loanProduct.loanPayments | orderBy: 'dueDate'; index as i ">
<tr style="max-height:22px;">
<td>
{{loanInstallments.dueDate | date:'MMMM yyyy'}}
</td>
<td>
{{loanInstallments.dueDate | date:'dd/MM/yyyy'}}
</td>
<td>
{{loanInstallments.installmentAmount | currency:'KES '}}
</td>
<td> {{loanInstallments.amountReceived| currency:'KES '}}
</td>
<td> {{loanInstallments.dateReceived | date:'dd/MM/yyyy'}}
</td>
<td>
{{loanInstallments.receiptNumber}}
</td>
</tr>
</tbody>
</table>
and here is scss
code这是
scss
代码
.mainContainer {
width: 100%;
// display: flex;
// flex-direction: column;
}
mat-card {
background: unset;
}
mat-card-title {
margin-top: 3%;
// margin-bottom: -1%;
background: #2D4431;
padding: 10px;
color: white;
border-radius: 4px;
}
table {
width: 100%;
height: 200px;
background: white;
padding: 20px;
border-radius: 4px;
}
tr:hover {
background-color: #2D4431;
color: white
}
.loanProductsHeader {
background: lightgray;
font-size: large;
}
textarea {
width: 100%;
height: 100px;
margin-top: 15px;
font-size: initial;
}
.editButton {
height: 25px;
}
:host ::ng-deep .mat-button-wrapper {
vertical-align: super
}
I tried the following knowing I added multiple as the real data is not available.我尝试了以下知道我添加了多个因为真实数据不可用。
CSS CSS
td { padding: 10px 0;}
HTML HTML
<tbody *ngFor="let loanInstallments of loanProduct.loanPayments | orderBy: 'dueDate'; index as i ">
<tr>
<td>
{{loanInstallments.dueDate | date:'MMMM yyyy'}}
</td>
<td>
{{loanInstallments.dueDate | date:'dd/MM/yyyy'}}
</td>
<td>
{{loanInstallments.installmentAmount | currency:'KES '}}
</td>
<td> {{loanInstallments.amountReceived| currency:'KES '}}
</td>
<td> {{loanInstallments.dateReceived | date:'dd/MM/yyyy'}}
</td>
<td>
{{loanInstallments.receiptNumber}}
</td>
</tr>
<tr>
<td>
{{loanInstallments.dueDate | date:'MMMM yyyy'}}
</td>
<td>
{{loanInstallments.dueDate | date:'dd/MM/yyyy'}}
</td>
<td>
{{loanInstallments.installmentAmount | currency:'KES '}}
</td>
<td> {{loanInstallments.amountReceived| currency:'KES '}}
</td>
<td> {{loanInstallments.dateReceived | date:'dd/MM/yyyy'}}
</td>
<td>
{{loanInstallments.receiptNumber}}
</td>
</tr>
<tr>
<td>
{{loanInstallments.dueDate | date:'MMMM yyyy'}}
</td>
<td>
{{loanInstallments.dueDate | date:'dd/MM/yyyy'}}
</td>
<td>
{{loanInstallments.installmentAmount | currency:'KES '}}
</td>
<td> {{loanInstallments.amountReceived| currency:'KES '}}
</td>
<td> {{loanInstallments.dateReceived | date:'dd/MM/yyyy'}}
</td>
<td>
{{loanInstallments.receiptNumber}}
</td>
</tr>
</tbody>
By the looks of the screenshot, this does not look like a CSS issue.从屏幕截图的外观来看,这看起来不像是 CSS 问题。 The whitespace is evenly dispersed and the row looks empty—are you sure you're getting all your data?
空白均匀分散,行看起来是空的——您确定要获取所有数据吗? It looks like some
loanPayments
have null data, ie indexes 0 and 2 of your array loanProduct
.看起来一些
loanPayments
数据,即您的数组loanProduct
索引 0 和 2。
If this is a valid state for your data, you can use ngIf
and only render the row if loanInstallments
is truthy, or if loanInstallments.dueDate
or loanInstallments.installmentAmount
(or any of its properties) exist to prevent whitespace from showing.如果这是您数据的有效状态,您可以使用
ngIf
并且仅在loanInstallments
为真,或者如果loanInstallments.dueDate
或loanInstallments.installmentAmount
(或其任何属性)存在以防止显示空格时才呈现该行。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.