I want my table cells to have a fixed height of 62px, I tried many solutions but I couldn't achieve this, and the one below is the closest one.
The problem I have is that the text inside my table cell is not displayed correctly, it's partially hidden.
The content of the table cells is dynamic, and my desired behavior, is for the table cell to grow in width to fit its content, and then the table will have a horizontal scroll since the overall width of the table would surpass its wrapper.
I know that white-space: nowrap; would solve the text overflowing issue, but I want the text to go to the second line because there is enough space for it line-height of 24px * 2 < 62px < line-height of 24px * 3. So it will either have one line or two lines depending on the cell min-width, and it the width of the cell will grow to fit it's content without having more than two lines, since three lines will result in a height > 62px
As for this solution:
Have table cell grow horizontally when cell content is large
I can't use it, since the min-content property is not supported by IE11.
How can I solve this?
.container {
width: 600px;
overflow: scroll:
}
table {
table-layout: fixed;
min-width: 100%;
overflow-x: auto;
}
tr>th:first-of-type,
tr>td:first-of-type {
min-width: 70px;
}
table thead th {
border-top-color: #d9deea;
border-bottom-color: #6b7790;
border-style: solid none solid none;
font-weight: 700;
padding: 24px 12px;
font-size: 14px;
color: #6b7790;
line-height: 16px;
border-width: 1px;
min-width: 124px;
}
tbody td {
color: #01216c;
line-height: 24px;
padding: 0 12px;
height: 62px;
font-size: 14px;
border-width: 1px;
border-bottom-color: #d9deea;
border-style: none none solid none;
overflow: hidden;
min-width: 124px;
}
td>span {
max-height: 62px;
display: block;
}
<div class="container">
<table>
<thead>
<tr>
<th>Header 1</th>
<th>Header 2</th>
<th>Header 3</th>
<th>Header 4</th>
</tr>
</thead>
<tbody>
<tr>
<td><span>Lorem ipsum.</span></td>
<td><span>Lorem ipsum dolor sit.</span></td>
<td><span>Lorem ipsum dolor sit, amet consectetur adipisicing elit. Voluptas, minus?</span></td>
<td><span>Lorem ipsum dolor sit amet consectetur adipisicing elit. Quo beatae quidem, molestiae sequi iusto amet voluptas maiores. Accusamus, dicta culpa?</span></td>
</tr>
<tr>
<td><span>Lorem ipsum.</span></td>
<td><span>Lorem ipsum dolor sit.</span></td>
<td><span>Lorem ipsum dolor sit, amet consectetur adipisicing elit. Voluptas, minus?</span></td>
<td><span>Lorem ipsum dolor sit amet consectetur adipisicing elit. Quo beatae quidem, molestiae sequi iusto amet voluptas maiores. Accusamus, dicta culpa?</span></td>
</tr>
<tr>
<td><span>Lorem ipsum.</span></td>
<td><span>Lorem ipsum dolor sit.</span></td>
<td><span>Lorem ipsum dolor sit, amet consectetur adipisicing elit. Voluptas, minus?</span></td>
<td><span>Lorem ipsum dolor sit amet consectetur adipisicing elit. Quo beatae quidem, molestiae sequi iusto amet voluptas maiores. Accusamus, dicta culpa?</span></td>
</tr>
<tr>
<td><span>Lorem ipsum.</span></td>
<td><span>Lorem ipsum dolor sit.</span></td>
<td><span>Lorem ipsum dolor sit, amet consectetur adipisicing elit. Voluptas, minus?</span></td>
<td><span>Lorem ipsum dolor sit amet consectetur adipisicing elit. Quo beatae quidem, molestiae sequi iusto amet voluptas maiores. Accusamus, dicta culpa?</span></td>
</tr>
</tbody>
</table>
</div>