CSS 显示: 表的最小高度不工作

有人知道我可以让最小高度与最新的浏览器工作?我使用的是 CSS 表格,它似乎忽略了最小高度。

<div style="background-color: red; display: table; min-height: 100px;">
abc
</div>

小提琴

70627 次浏览

When using tables, height essentially is min-height, as tables always stretch. Just get rid of the "min-" and it will work as you expect.

Use height: 1px; on the table or any value. Basically you need to give table some height to make it work with min-height. Having only min-height won't work on tables on firefox.

Whenever you are using display:table; or any deeper property like display:table-cell; consider using height instead of min-height. As in tables height = min-height considering the auto-span feature in them.

Solution for Firefox

Add height to unlock setting the min-height

div {
display: table;
width: 100%;
height: 0;
min-height: 100px;
}

The number in height can be any other real value less or equal to min-height for making it work as expected.