Min-Height and Table Cells

Can I use a min-height for table, tr or td?

It's not a nice solution but try it like this:

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

and set the divs to the min-height:

div {
min-height: 300px;
}

Hope this is what you want ...

CSS display: table min-height not working

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.

How to define minimum height for tbody in CSS

Why you want to do this?

Min-height and height applies to block level elements and table isn't a block level element.
Wrap your table inside a div (say div.table-wrap) and apply minimum height to that div.

If you don't want table layout isn't important to you, then just add display:block to the CSS of tbody.

Min-height 100% for TABLE divs

replace:

min-height:100%;

with

height:100%;

works perfectly for chrome and FF here.

How to set table cell width and height in Bootstrap tables

Bootstrap sets the table at 100% width, so you need to override that. Here is what I did:

table {
table-layout:fixed;
width: inherit !important;
}
td, th {
width:150px !important;
height:75px !important;
max-width:150px !important;
max-height:75px !important;
min-width:150px !important;
min-height:75px !important;
}
<head>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" integrity="sha384-JcKb8q3iqJ61gNV9KGb8thSsNjpSL0n8PARn9HuZOnIxN0hoP+VmmDGMN5t9UJ0Z" crossorigin="anonymous">
</head>
<body>
<table class="table table-bordered">
<thead>
<tr>
<th scope="col">#</th>
<th scope="col">First</th>
<th scope="col">Last</th>
<th scope="col">Handle</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row">1</th>
<td style="width:150px; height:75px">Mark</td>
<td>Otto</td>
<td>@mdo</td>
</tr>
<tr>
<th scope="row">2</th>
<td>Jacob</td>
<td>Thornton</td>
<td>@fat</td>
</tr>
<tr>
<th scope="row">3</th>
<td colspan="2">Larry the Bird</td>
<td>@twitter</td>
</tr>
</tbody>
</table>

<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.1/dist/umd/popper.min.js" integrity="sha384-9/reFTGAW83EW2RDu2S0VKaIzap3H66lZH81PoYlFhbGU+6BZp6G7niu735Sk7lN" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js" integrity="sha384-B4gt1jrGC7Jh4AgTPSdUtOBvfO8shuf57BaghqFfPlYxofvL8/KUEfYiJOMMV+rV" crossorigin="anonymous"></script>
</body>


Related Topics



Leave a reply



Submit