Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

CSS

CSS Flexbox layout with calc()

I am having a heck of a time getting a 100% tall content area to work. Its supposed to be 100% of the screen minus the header and footer height (and their combined margins). Setting min-height to 100% should make sure its 100% but can grow if needed. Yet there is an odd something not firing off here.

.site-main {
  min-height: calc(100% - 15.6em); 
  flex-grow: 5;
}

I've provided a pen of my work thus far, which gives a better overview of what I am working on.

http://codepen.io/johnweland/pen/GJxBPJ?editors=110

1 Answer

Guil Hernandez
STAFF
Guil Hernandez
Treehouse Teacher

Hi John Weland,

For .site-main to be 100% tall, the height for .flex-row (the parent element) also need to be set to 100%.

Hope this helps.

OK so it doesn't force the parent, building a 'sorta' grid system in flex-box ain't easy lol. Thanks.

I updated the pen. My class names and conventions are a little hacky but it works!! Thanks!

Guil Hernandez
Guil Hernandez
Treehouse Teacher

Nice! Glad to see that it worked. Nope, it doesn't force the parent's height; it expands based on the available height.