Setting table row height

前端 未结 8 1929
旧时难觅i
旧时难觅i 2020-12-25 09:07

I have this code:

相关标签:
8条回答
  • 2020-12-25 09:37

    If you are using Bootstrap, look at padding of your tds.

    0 讨论(0)
  • 2020-12-25 09:41

    line-height only works when it is larger then the current height of the content of <td> . So, if you have a 50x50 icon in the table, the tr line-height will not make a row smaller than 50px (+ padding).

    Since you've already set the padding to 0 it must be something else,
    for example a large font-size inside td that is larger than your 14px.

    0 讨论(0)
  • 2020-12-25 09:44

    once I need to fix the height of a particular valued row by using inline CSS as following..

    <tr><td colspan="4" style="height: 10px;">xxxyyyzzz</td></tr>
    
    0 讨论(0)
  • 2020-12-25 09:46

    As for me I decided to use paddings. It is not exactly what you need, but may be useful in some cases.

    table td {
        padding: 15px 0;
    }
    
    0 讨论(0)
  • 2020-12-25 09:49

    try this:

    .topics tr { line-height: 14px; }

    0 讨论(0)
  • 2020-12-25 09:49

    I found the best answer for my purposes was to use:

    .topics tr { 
        overflow: hidden;
        height: 14px;
        white-space: nowrap;
    }
    

    The white-space: nowrap is important as it prevents your row's cells from breaking across multiple lines.

    I personnally like to add text-overflow: ellipsis to my th and td elements to make the overflowing text look nicer by adding the trailing fullstops, for example Too long gets dots...

    0 讨论(0)
提交回复
热议问题