How to dimension aside and center div according to the height of the screen

0

I'm trying to scale the side menu and content div between the header and the footer so that it fills the entire screen even though I do not have a lot of content. if it has a lot of content, it would have the scroll bar.

Like this:

Howshoulditbe(Photoshop):

Code:

<!DOCTYPEhtml><html><head><metacharset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script><scriptsrc="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>

    <style>
        html,body{
            min-height: 100%;  
        }

        header {
            height: 100px;
            background-color: blue;
        }

        .container {
            background-color: aqua;
        }

        aside {
            background-color: blueviolet;
            height: 100%;
        }

        main {
            background-color: gold;
            height: 100%;
        }

        footer {
            height: 150px;
            background-color: red;
            position: absolute;
            bottom: 0;
            width: 100%;
        }
    </style>
</head>

<body>
    <header>
    </header>

    <div class="container">
        <aside class="col-sm-3">
            <h1>MENU</h1>
        </aside>

        <main class="col-sm-9">
            <p>Conteudo</p>
            <p>Conteudo</p>
            <p>Conteudo</p>
            <p>Conteudo</p>
            <p>Conteudo</p>
            <p>Conteudo</p>
            <p>Conteudo</p>
            <p>Conteudo</p>
        </main>
    </div>

    <footer>
    </footer>
</body>
</html>
    
asked by anonymous 30.07.2017 / 23:55

3 answers

0

For a div to have 100% height, your parents also need to be at 100%. Here is the code:

<style>
    html,body{
        height: 100%;  
    }

    header {
        height: 100px;
        background-color: blue;
    }

    .container {
        background-color: aqua;
        height: 100%; 
    }

    aside {
        background-color: blueviolet;
        height: 100%;
    }

    main {
        background-color: gold;
        height: 100%;
    }

    footer {
        height: 150px;
        background-color: red;
        position: relative;
        bottom: 0;
        width: 100%;
    }
</style>
    
31.07.2017 / 15:38
0

To keep the div to the end of the page just add in the given element.

.elemento
{
   height: 100vh;
}
    
31.07.2017 / 15:43
0

You should give height value either 100% or 100vh this to have a responsive site following the example you can also see this because it helps with formatting Google Link

html, body, 
    margin: 0;
    padding:0;
    width: 100%;
    height: 100vh;

}
    
09.11.2018 / 17:27