Reputation: 217
I have this code
<!-- <body> (automatically added by jsFiddle) -->
<header id="header">
<h1>Title</h1>
</header>
<div id="mainContent">
Some text. End.<br />
</div>
<!-- </body> -->
How can I stretch #mainContent
to fill all the available space below #header
?
That's for a Windows 8 app, so I can use CSS 3 (including -ms-grid-*) and JavaScript without worrying about browser support!
Upvotes: 0
Views: 172
Reputation: 92803
You can use display:table property for this:
HTML
<div class="parent">
<header id="header">
<h1>Title</h1>
</header>
<div id="mainContent">
Some text. End.<br />
</div>
</div>
CSS
body,html{
height:100%;
}
.parent{
display:table;
height:100%;
box-sizing:border-box;
width:100%
}
#header, #mainContent {
background:red;
display:table-row;
}
/* How can I make #header to fill the full available left space */
#header {
height:10%;
background:green;
}
Check this http://jsfiddle.net/cD2RK/3/
Upvotes: 2