Can I use the minimum height for a table, tr or td?

I am trying to show some reception details in a table.

I want this table to have a minimum height for displaying products. Therefore, if there is only one product, at the end of the table there will be at least some free space. On the other hand, if there are 5 or more products, this will not be empty space.

I tried with this css:

table,td,tr{ min-height:300px; } 

But it does not work.

Thanks in advance.

+85
html css
Oct 17 '13 at 16:21
source share
7 answers

This is not a good solution, but try like this:

 <table> <tr> <td> <div>Lorem</div> </td> </tr> <tr> <td> <div>Ipsum</div> </td> </tr> </table> 

and set divs to min-height:

 div { min-height: 300px; } 

Hope this is what you want ...

+32
Oct 17 '13 at 16:28
source share

height for td works like min-height :

 td { height: 100px; } 

instead

 td { min-height: 100px; } 

Table cells will grow when the content is inappropriate.

https://jsfiddle.net/qz70zps4/

+291
Aug 15 '14 at 15:11
source share

In a solution without a div , a pseudo-element of type ::after in the first td in the line with min-height . Save your HTML code.

 table tr td:first-child::after { content: ""; display: inline-block; vertical-align: top; min-height: 60px; } 
+21
May 9 '16 at 12:07
source share

In CSS 2.1, the effects of "min-height" and "max-height" on tables, inline tables, table cells, table rows, and row groups are undefined.

So try wrapping the contents in a div and give the div a min-height jsFiddle here

 <table cellspacing="0" cellpadding="0" border="0" style="width:300px"> <tbody> <tr> <td> <div style="min-height: 100px; background-color: #ccc"> Hello World ! </div> </td> <td> <div style="min-height: 100px; background-color: #f00"> Goog MOrning ! </div> </td> </tr> </tbody> </table> 
+9
Oct 17 '13 at 16:31
source share

if you set style = "height: 100px;" on td, if td has content that enlarges the cell more, it will not require a minimum height on td.

+5
Jul 15 '15 at 21:59
source share

Just use the css notation min-height for one of the cells of your table row. Works with older browsers.

 .rowNumberColumn { background-color: #e6e6e6; min-height: 22; } <table width="100%" cellspacing="0" class="htmlgrid-table"> <tr id="tr_0"> <td width="3%" align="center" class="readOnlyCell rowNumberColumn">1</td> <td align="left" width="40%" id="td_0_0" class="readOnlyCell gContentSection">411978430-Intimate:Ruby:Small</td> 
0
Mar 21 '17 at 1:41 on
source share

Tables and cells of the table do not use the min-height , setting their height will be the minimum height, since the tables will expand if the contents stretch them.

0
Sep 26 '18 at 20:29
source share



All Articles