2016-06-08 103 views
3

我使用引导程序创建了一些具有动态高度的列。当任何表格单元必须折叠时,使所有行更高,其他单元高度的内容保持不变。动态行高问题表

这里是正在发生的例子:

/* 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

我想跨度有细胞高度,它的所有背景变为红色(但不所有的细胞)。

我尝试在某些单元格和行上添加height:100%,但不起作用。我想自动保持行高,因此添加固定高度不是解决方案。我已经看到一些解决方案,使用div的像this,但我想保持一张桌子。

+1

我不明白这个问题。那么你是否希望带有红色背景的跨度填满单元格? –

+0

它希望它填满整个跨度的高度 –

+0

我找到了一个解决方案,查看我的发贴波纹管。仍然不能标记它是正确的。 –

回答

1

我发现了如何使这项工作,从here的一点点帮助。

下面是最终的结果:

/* 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>

希望这有助于在未来的人。问题主要在于显示类型和高度。

-1

你可以在这里试试这个:height: auto;

编辑:我missunderstood的问题。如果bootstrap添加了一些,您可以尝试重置单元格的填充。

+0

它确实添加了一些填充,我删除了它(但忘记在示例中做),但这不是问题。问题是因为显示器类型(我猜)它有点增加了自动填充的元素(抱歉,因为不是非常技术性的问题,但问题是,我不明白如何自动填充显示器的作品) –

+0

也许有一个在保证金,你必须删除 – Exar

+0

不,这个问题不是边际,你可以看到我的工作 –

2

您可以将此checkbox写入个人td并将class = "input-group-addon"指定为td

<tr> 
    <th>Energia Elétrica</th> 
    <td>Test</td> 
    <td class="checkbox-table"> 
    <div class="input-group"> 
     <input type="number" class="form-control" min="0/"> 

    </div> 
    </td> 
    <td class="input-group-addon"><input type="checkbox">NS</td> 
</tr> 

检查这个http://www.bootply.com/xGm9xGA1G7

+0

我的工作,但它会复杂的一点点,因为我们分开输入复选框。但如果没有其他事情发生,它会做,谢谢。如果我没有其他解决方案,我会接受 –

+0

我想出了一个解决方案,所以这不是必需的。无论如何感谢=) –