How to hide Table Row Overflow?

前端 未结 7 750
故里飘歌
故里飘歌 2020-11-28 09:16

I have some html tables where the textual data is too large to fit. So, it expands the cell vertically to accommodate for this. So now rows that have the overflow are twic

相关标签:
7条回答
  • 2020-11-28 09:55

    Here´s something I tried. Basically, I put the "flexible" content (the td which contains lines that are too long) in a div container that´s one line high, with hidden overflow. Then I let the text wrap into the invisible. You get breaks at wordbreaks though, not just a smooth cut-off.

    table {
        width: 100%;
    }
    
    .hideend {
        white-space: normal;
        overflow: hidden;
        max-height: 1.2em;
        min-width: 50px;
    }
    .showall {
        white-space:nowrap;
    }
    
    <table>
        <tr>
            <td><div class="showall">Show all</div></td>
            <td>
                <div class="hideend">Be a bit flexible about hiding stuff in a long sentence</div>
            </td>
            <td>
                <div class="showall">Show all this too</div>
            </td>
        </tr>
    </table>
    
    0 讨论(0)
提交回复
热议问题