Table with dynamic row height issue

Rui Cardoso

I'm creating a table with some columns which has dynamic height using bootstrap. When any of the table cells has to collapse, making all the rows higher, the content of the other cells height stays the same.

Here is an example of what is happening:

/* CSS used here will be applied after bootstrap.css */

.input-group input, .input-group span{
  border: none;
}

span.input-group-addon {
  background-color: red;
}

.table-bordered>tbody>tr>td, .table-bordered>tbody>tr>th, .table-bordered>tfoot>tr>td, .table-bordered>tfoot>tr>th, .table-bordered>thead>tr>td, .table-bordered>thead>tr>th{
  vertical-align: middle;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet"/>
<table class="table table-bordered">
  <tbody>
    <tr>
      <th>Big word to test multiple line</th>
      <td>Teste</td>
      <td class="checkbox-table">
        <div class="input-group">
          <input type="number" class="form-control" min="0/">
          <span class="input-group-addon"><input type="checkbox">NS</span>
        </div>
      </td>
    </tr>
  </tbody>
</table>

http://www.bootply.com/yItLpVcKof

I want the span to have the cell height so all of it's background becomes red (but not the all cell).

I've try adding height:100% on some cells and rows but doesn't work. I want to keep the row height automatically, so adding a fixed height isn't a solution. I've seen some solutions by using div's like this but I wanted to keep it a table.

Rui Cardoso

I found out how to make this work, with a little bit of help from here.

Here is the final result:

    /* CSS used here will be applied after bootstrap.css */

.table .checkbox-container {
  vertical-align: top;
  padding: 0;
}

.table .checkbox-container .input-group {
  height: 100%;
}

.table .checkbox-container .input-group-addon {
  border: none;
  border-radius: 0;
  background-color: red;
}

.table .checkbox-container .input-group > input {
  padding: 0;
  border: none;
  border-radius: 0;
  outline: none;
  height: 100%;
}

.table .box {
  height: 100%;
  padding: 0;
  display: inline-block;
}

.table-bordered>tbody>tr>td, .table-bordered>tbody>tr>th, .table-bordered>tfoot>tr>td, .table-bordered>tfoot>tr>th, .table-bordered>thead>tr>td, .table-bordered>thead>tr>th{
  vertical-align: middle;
}
    <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet"/>
    <table class="table table-bordered">
  <tbody>
    <tr>
      <th>Big word to test multiple line</th>
      <td>Teste</td>
      <td class="checkbox-container">
        <div class="box">
          <div class="input-group fill-during">
            <input id="B17" type="number" class="form-control" min="0/">
            <span class="input-group-addon"><input type="checkbox">NS</span>
          </div>
        </div>
      </td>
    </tr>
  </tbody>
</table>

Hope it helps anyone in the future. The problem was mainly on the display type and heights.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Table with dynamic row height issue

From Dev

Dynamic height of UITableview Issue

From Dev

Can't change row height in Xcode 6 dynamic table

From Dev

HTML Table Row nth-child Dynamic Content Issue

From Dev

Dynamic height of table is not set

From Dev

Decreasing table row height in Word 2011 (possibly specific issue with end of row formatting)

From Dev

Dynamic Row Height and sizeWithAttributes Warning

From Dev

Product list row with dynamic height

From Dev

RecyclerView GridLayoutManager and dynamic row height

From Dev

Table Row attr() Issue

From Dev

Dynamic table row creation

From Dev

Highcharts dynamic height with table layout

From Dev

How to place background images on HTML emails with dynamic height from table row?

From Dev

Unable to set row height equal to table height

From Dev

Reducing HTML Table Row Height

From Dev

Auto height of table-row

From Dev

Change table row height - Bootstrap

From Dev

Active Reports Table Row Height

From Dev

Table with variable row height in tkinter

From Dev

UITableView deleting row reduced table row height

From Dev

Jquery Dynamic table column issue

From Dev

Make multiple links in a row the same dynamic height

From Dev

uicollectionview's dynamic height as per row values

From Dev

Dynamic UITableView row height using UIStackView?

From Dev

UITableViewCell dynamic height breaks after insert row

From Dev

Dc.js - Row Chart with dynamic height

From Dev

Adjust google maps height dynamic in row

From Dev

TableView Dynamic Row Height Not Getting Called

From Dev

Make multiple links in a row the same dynamic height