Why are you using display: table-row; declarations display: table-row; ? That is unnecessary. Remove display: table-row; declarations display: table-row; add the declaration box-sizing: border-box; into your textarea selector, and everything will be installed:
.container { height: 220px; width: 220px; background-color: pink; } .container > textarea { width: 100%; height: 100%; background-color: cyan; box-sizing: border-box; } .container > div { width: 100%; height: 100%; background-color: cyan; }
Fiddle
EDIT:
The CSS above makes the text area an overflow of the parent div.
Here is the updated answer:
HTML
<div class="container"> <div class="button-wrapper"> <button>X</button> </div> <div class="textarea-wrapper"> <textarea></textarea> </div> </div>
CSS 2
.container { height: 220px; width: 220px; background-color: pink; position: absolute; } .container textarea { width: 100%; height: 100%; background-color: rgba(255, 255, 0, 0.5); box-sizing: border-box; } .container > div { background-color: cyan; } .container .button-wrapper { background-color: yellow; height: 26px; } .container .textarea-wrapper { background-color: green; position: absolute; top: 26px; width: 100%; bottom: 0; }
CSS 3 (using calc function)
.container { height: 220px; width: 220px; background-color: pink; } .container textarea { width: 100%; height: 100%; background-color: rgba(255, 255, 0, 0.5); box-sizing: border-box; } .container > div { background-color: cyan; } .container .button-wrapper { background-color: yellow; height: 26px; } .container .textarea-wrapper { background-color: green; height: calc(100% - 26px); }
Here are the scripts that show both solutions:
CSS 2
CSS 3
Eric morrand
source share