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

100% screen size problem

Can somebody tell me what is the problem here?

I have THIS file. with css:

.mainpanel {
    background-color: blue;
    min-height: 500px;
    width: 100%;
    height: 100%;
}


.secondpanel {
    background-color: red;
    width: 100%;
    height: 100%;
    min-height: 500px; 
}

But page always show min-height and does not span 100% height?

Thank you

3 Answers

The height of a block element corresponds to its content, unless you specify a certain height. Giving this element a percentage height won't really do anything unless the parent element has a specified height.

I want to create something like this website: http://www.diehlgroup.com/ so that it detects screensize and give me fullscreen slideshow, isn't that possible?

You might try setting your div like this:

div {
     height:100vh;
}

This will set the div to 100% of the viewport.

Thanks :)