简体   繁体   English

为什么我的第一行高度高于其他行 HTML

[英]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.dueDateloanInstallments.installmentAmount (或其任何属性)存在以防止显示空格时才呈现该行。

为什么身高是<form>超过高度<textarea>&lt;i&gt;inside it?&lt;/div&gt;&lt;/i&gt;&lt;b&gt;在里面?&lt;/div&gt;&lt;/b&gt;</textarea><div id="text_translate"><p> 我的问题的最小示例: </p><p></p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"><div class="snippet-code"><pre class="snippet-code-js lang-js prettyprint-override"> console.log(document.getElementById('form').offsetHeight) console.log(document.getElementById('textarea').offsetHeight)</pre><pre class="snippet-code-css lang-css prettyprint-override"> form { background: orange; } textarea { background: lightblue; border: 0; box-sizing: border-box; height: 100px; }</pre><pre class="snippet-code-html lang-html prettyprint-override"> &lt;form id="form"&gt;&lt;textarea id="textarea"&gt;&lt;/textarea&gt;&lt;/form&gt;</pre></div></div><p></p><p> &lt;textarea&gt;的高度为 100px,但&lt;form&gt;的高度为 4px? &lt;textarea&gt;的额外 4px 高度从何而来? 如何消除多余的高度?</p></div></form> - Why is the height of <form> more than the height of the <textarea> inside it?

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我如何在 html 中制作一个表格,第一行只有 1 列,其他行超过 1 - How do i make a table in html with first row having 1 column only and other rows having more than 1 为什么我的html表占用的空间超过了必要的高度? - Why is my html table taking up more height than necessary? 无法访问第一行以外的其他行的获取值 - Unable to access get values of other rows other than the first row 一排内的第一张图片比其他html / css小 - First images inside a row smaller than other ones html/css 同一张图片的第一列中的图像高度比所有其他列(CSS,HTML)高 - Height of image in the first column of the same picture is slightly taller than all other columns, CSS, HTML 如何强制标题表行与其他表行的高度相同? - How do I force my header table row to be the same height as the other table rows? 为什么我的图像在背景空间中占据的高度比图像本身高? - Why is my image taking up more height in the background space than the image itself? 具有2行的HTML表。 1固定高度,1100%。 比窗口大。 为什么? - HTML Table with 2 rows. 1 Fixed height, 1 100%. Larger than window. Why? 为什么 <br> 元素的高度比line-height高 - Why the <br> element has more height than line-height 为什么身高是<form>超过高度<textarea>&lt;i&gt;inside it?&lt;/div&gt;&lt;/i&gt;&lt;b&gt;在里面?&lt;/div&gt;&lt;/b&gt;</textarea><div id="text_translate"><p> 我的问题的最小示例: </p><p></p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"><div class="snippet-code"><pre class="snippet-code-js lang-js prettyprint-override"> console.log(document.getElementById('form').offsetHeight) console.log(document.getElementById('textarea').offsetHeight)</pre><pre class="snippet-code-css lang-css prettyprint-override"> form { background: orange; } textarea { background: lightblue; border: 0; box-sizing: border-box; height: 100px; }</pre><pre class="snippet-code-html lang-html prettyprint-override"> &lt;form id="form"&gt;&lt;textarea id="textarea"&gt;&lt;/textarea&gt;&lt;/form&gt;</pre></div></div><p></p><p> &lt;textarea&gt;的高度为 100px,但&lt;form&gt;的高度为 4px? &lt;textarea&gt;的额外 4px 高度从何而来? 如何消除多余的高度?</p></div></form> - Why is the height of <form> more than the height of the <textarea> inside it?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM