I'm trying to understand why a table cell containing inline elements doesn't wrap them tightly.
To be more specific I would expect the cell to be as tall as the highest contained element. But in my example the cell is taller than it should be. There is a bottom gap under it's content and moreover, the content is not vertically aligned - the glyphicon should be in the middle.
I would appreciate for any explanation.
Here is my code:
* {
box-sizing: border-box;
}
td {
border: 1px solid black;
vertical-align: middle;
padding: 0;
}
.title-content {
display: inline-table;
}
.color-box, .color-box + span {
display: table-cell;
vertical-align: middle;
}
.color-box {
padding: 0 5px;
}
.color-box-border {
border: 1px solid #cccccc;
height: 16px;
padding: 1px;
width: 10px;
}
.color-box-canvas {
height: 100%;
width: 100%;
background-color: red;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet"/>
<table>
<tr>
<td>
<span class="glyphicon glyphicon-minus"></span>
<div class="title-content">
<div class="color-box">
<div class="color-box-border">
<div class="color-box-canvas"></div>
</div>
</div>
<span>NODE</span>
</div>
</td>
</tr>
</table>