G
G
grinch_asd2018-03-22 22:39:33
css
grinch_asd, 2018-03-22 22:39:33

Block height to full screen?

Hello.
The task is this. The maximum screen height is 100%. those. The scrollbar should not appear in any case. There is a fixed height header and footer. They are located respectively at the top and bottom of the screen. You need to add a block between them so that its height completely occupies the free space between the header and footer, regardless of the content. All this needs to be done without using js.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
L
levchak0910, 2018-03-22
@grinch_asd

<div id="wrap">
    <header></header>
    <main></main>
    <footer></footer>
</div>

html, body {margin: 0}
#wrap {
    border: 2px solid #000;
    display: flex;
    flex-flow: column nowrap;
    width: 100vw;
    height: 100vh;
}
header {
    flex: 0 0 100px;
    background: green;
}
footer {
    flex: 0 0 150px;
    background: blue;
}
main {
    flex: 1 1 auto;
    background: yellow;
}

A
aloky, 2018-03-22
@aloky

flexwill help)

P
Peter, 2018-03-22
@Morpheus_God

I dare to suggest that it is worth trying to set this as a percentage.
Let's say header and footer are 20 percent each and 60 percent is the container you need.
Like this?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question