I was reading How are `display: table-cell` widths calculated? and bootstrap input groups. Consider the following example
https://jsfiddle.net/kb23jLL3/
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<form class="bs-example bs-example-form" data-example-id="simple-input-groups">
<div class="input-group">
<div class="input-group-addon" id="basic-addon1">@</div>
<div class="form-control" placeholder="Username" aria-describedby="basic-addon1"> </div>
</div>
</form>
The .form-control
has width 100% but it grows only to take the available width in the congaing table. So far so good. So I expect .form-control
to never grow beyond the limits of containing table. But if I give width more than 100% then it grows out of the containing table's boundaries and if I give width less than 100% then it doesn't take the available space. E.g. 100% + case:
https://jsfiddle.net/kb23jLL3/1/
.input-group .form-control {
width: 110%;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<form class="bs-example bs-example-form" data-example-id="simple-input-groups">
<div class="input-group">
<div class="input-group-addon" id="basic-addon1">@</div>
<div class="form-control" placeholder="Username" aria-describedby="basic-addon1"> </div>
</div>
</form>
You can see the horizontal scroll bar now appearing. Similarly consider the following example where I give width less than 100%:
https://jsfiddle.net/kb23jLL3/2/
.input-group .form-control {
width: 90%;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<form class="bs-example bs-example-form" data-example-id="simple-input-groups">
<div class="input-group">
<div class="input-group-addon" id="basic-addon1">@</div>
<div class="form-control" placeholder="Username" aria-describedby="basic-addon1"> </div>
</div>
</form>
Why does 100% width on table-cell mean the available width? Should 100% width mean to take 100% of the containing element?Please provide some reference which mentions this behavior.