-1

I am working on my new site and I have 4 sections header, nav, main and footer.

If you make the window smaller on the vertical side the navbar height works propperly.

working

But if you make the window smaller on the horizontal side, so the content goes down.

not working

I don't understand why the navbar isn't 100% anymore? The body is 100% and the navbar should have the same height but it isn't? body is 100%

nav is 100%

I tried 100vh but it isn't working either and I think 100% should work?

Dylan
  • 33
  • 4
  • Please add meaningful code and a problem description here. Don't just link to the site that needs fixing - otherwise, this question will lose any value to future visitors once the problem is solved or if the site you're linking to is inaccessible. Posting a [Minimal, Complete, and Verifiable example (MCVE)](http://stackoverflow.com/help/mcve) that demonstrates your problem would help you get better answers. For more info, see [Something on my web site doesn't work. Can I just paste a link to it?](http://meta.stackexchange.com/questions/125997/) Thanks! – j08691 Nov 16 '16 at 15:51
  • Link:-http://stackoverflow.com/questions/6654958/make-body-have-100-of-the-browser-height – Razia sultana Nov 16 '16 at 15:56
  • @Raziasultana doesn't work for me. footer isn't at the bottom anymore. – Dylan Nov 16 '16 at 16:01
  • @j08691 sorry! but therefor i provided some screenshots – Dylan Nov 16 '16 at 16:02
  • Ok i'll try.... – Razia sultana Nov 16 '16 at 16:03
  • its already fixed! (hint hint) – Dylan Nov 16 '16 at 16:10

5 Answers5

2

Make your <nav> position fixed.

Use:

nav {
  position: fixed;
}

Instead of:

nav {
  position: absolute;
}

Hope this helps!

Saurav Rastogi
  • 9,575
  • 3
  • 29
  • 41
0

Try it:-

html {
  height: 100%;
}
body {
  min-height: 100%;
}
Razia sultana
  • 2,168
  • 3
  • 15
  • 20
0

have you tried adding a page-wrapper? something like this

<body>
    <div class="page-wrapper">
        <header></header>
        <nav></nav>
        <main>
            <p>...</p>
        </main>
        <footer></footer>
    </div>
</body>

.page-wrapper {
    postion:relative;
    display: block;
    width: 100%;
    height: 100%;
}
Scott Murphy
  • 136
  • 5
0

To Get 100% height on body HTML need to have 100% height first , first Make your HTML height 100%;

 html {
      height:100%;
}

Then the body :

body {
height:100%;
}

finally element you want it to be 100% heigh

nav {
height:100%;
}
Neinrappeur Zaki
  • 397
  • 2
  • 12
0

make the nav position: fixed;

html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td,
article, aside, canvas, details, embed,
figure, figcaption, footer, header, hgroup,
menu, nav, output, ruby, section, summary,
time, mark, audio, video {
  margin: 0;
  padding: 0;
  border: 0;
  font-size: 100%;
  font: inherit;
  vertical-align: baseline; }

/* HTML5 display-role reset for older browsers */
article, aside, details, figcaption, figure,
footer, header, hgroup, menu, nav, section {
  display: block; }

body {
  line-height: 1; }

ol, ul {
  list-style: none; }

blockquote, q {
  quotes: none; }

blockquote:before, blockquote:after,
q:before, q:after {
  content: '';
  content: none; }

table {
  border-collapse: collapse;
  border-spacing: 0; }

html, body {
  width: 100%;
  height: 100%;
  overflow: auto;
  background-color: #f9f9f9; }

body {
  position: relative; }

header {
  width: 100%;
  height: 55px;
  background-color: #47aadd;
  position: relative;
  z-index: 101; }

nav {
  width: 100px;
  height: 100%;
  background-color: #363636;
  float: left;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 100; }

footer {
  width: 100%;
  height: 35px;
  background-color: #47aadd;
  float: left;
  position: relative; }

main {
  max-width: calc(100% - 100px);
  min-height: calc(100% - 90px);
  padding: 25px;
  float: right;
  position: relative;
  overflow:auto;

}

*, *:before, *:after {
  box-sizing: border-box; }
<html lang="en"><head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>

</head>
<body>
    <header></header>
    <nav></nav>
    <main>
        <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum commodo dignissim risus, at mollis dui fringilla vitae. Vestibulum cursus consectetur nunc, ut aliquam urna rutrum a. Proin sem nunc, semper a sem et, blandit commodo diam. Nam rhoncus lobortis ligula quis eleifend. Aliquam facilisis tempor lorem, nec tristique mi condimentum nec. Ut in semper odio, in fermentum nibh. Aenean feugiat massa risus, vel tempor leo feugiat non. Cras a iaculis orci.

            Sed maximus nunc eu gravida sagittis. Ut et justo ut est aliquam posuere. Nullam nisi neque, laoreet vel velit vel, scelerisque condimentum lectus. Nam dolor nisl, consequat vitae elementum eget, eleifend quis felis. Nullam vel accumsan ex, eget elementum magna. Sed ut erat fermentum, efficitur nibh tempus, mollis nibh. Vivamus interdum nisi sem, ac sollicitudin sem faucibus eget. Nunc ut leo eget enim posuere luctus. In hac habitasse platea dictumst. Ut condimentum tincidunt lorem, eget eleifend mi malesuada eu. Nam porttitor mi a augue rutrum mattis. Sed pellentesque vitae tortor ut pulvinar. Nam eget tortor tellus.

            Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Nam tristique eros nisl, quis commodo augue gravida nec. Aenean vel ornare quam. Donec commodo purus et suscipit fringilla. Sed ultrices justo vitae lacus egestas malesuada. Vivamus ante dui, consectetur sit amet fringilla vitae, interdum dictum enim. In congue sem diam. Suspendisse eros ligula, porta vel tincidunt vitae, condimentum a nisl. Vestibulum eget tristique quam, ut mollis nisl. Integer condimentum tincidunt est, in viverra ipsum ullamcorper ut. Morbi molestie, lectus sit amet finibus varius, libero nunc vestibulum neque, id luctus sapien ante ut justo. Suspendisse nisl orci, ultrices in magna et, dictum congue nisl. In at vestibulum velit. Nulla sed diam ex. Pellentesque a posuere nibh, sit amet vulputate sem.

            Duis id mollis est. Duis tellus odio, aliquet at nibh eu, tristique consequat nunc. Nullam consequat sapien eget odio tempor, vel sagittis turpis aliquet. Maecenas id nisl euismod, feugiat dui at, vestibulum tortor. Phasellus at sem commodo ligula semper gravida. Duis sapien orci, blandit id viverra quis, venenatis sed est. Duis urna magna, hendrerit id quam pellentesque, posuere suscipit metus. Donec laoreet commodo odio sit amet consequat.

            Pellentesque sem dolor, fringilla ac eros nec, commodo maximus turpis. Proin posuere ut metus mollis porttitor. Pellentesque pellentesque pulvinar lobortis. Curabitur mollis dolor eu sapien ullamcorper, et tristique felis tempus. Cras vulputate neque eget tristique imperdiet. Proin lobortis luctus sem, ac ullamcorper sem eleifend nec. Aliquam vehicula ante non enim sodales, id volutpat libero dapibus. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis accumsan dolor nec felis viverra vehicula. Nam ut aliquam mauris. Maecenas vitae purus ligula.</p>
    </main>
    <footer></footer>

</body></html>
jafarbtech
  • 6,842
  • 1
  • 36
  • 55