2016-11-16 35 views
-1

Ich arbeite an meiner neuen Website und ich habe 4 Sektionen Header, Nav, Main und Footer.CSS 100% Höhe funktioniert nicht aber Körper ist 100% Höhe?

Wenn Sie das Fenster auf der vertikalen Seite verkleinern, funktioniert die Höhe der Navigationsleiste korrekt.

working

Aber wenn Sie das Fenster kleiner machen auf der horizontalen Seite, so dass der Inhalt untergeht.

not working

Ich verstehe nicht, warum die navbar nicht mehr zu 100%? Der Körper ist 100% und die Navbar sollte die gleiche Höhe haben, aber es ist nicht? body is 100%

nav is 100%

versuchte ich 100vh aber es ist auch nicht arbeiten, und ich denke, sollte 100% arbeiten?

+0

Bitte fügen Sie hier einen aussagekräftigen Code und eine Problembeschreibung hinzu. Verknüpfen Sie nicht einfach mit der Website , die behoben werden muss - andernfalls wird diese Frage an zukünftige Besucher verloren gehen, sobald das Problem gelöst ist oder wenn die Website, auf die Sie verlinken, nicht erreichbar ist. Wenn Sie ein [Minimales, vollständiges und verifizierbares Beispiel (MCVE)] (http://stackoverflow.com/help/mcve) schreiben, dass Ihr Problem demonstriert, können Sie bessere Antworten erhalten. Weitere Informationen finden Sie unter [Etwas auf meiner Website funktioniert nicht. Kann ich einfach einen Link einfügen?] (Http://meta.stackexchange.com/questions/125997/) Danke! – j08691

+0

Link: -http: //stackoverflow.com/questions/6654958/make-body-have-100-of-the-browser-height –

+0

@ Raziasultana funktioniert nicht für mich. Fußzeile ist nicht mehr am unteren Rand. – Dylan

Antwort

2

Machen Sie Ihre <nav> Position fixed.

Verwendung:

nav { 
    position: fixed; 
} 

Statt:

nav { 
    position: absolute; 
} 

hoffe, das hilft!

+0

einfach, aber es funktioniert! danke – Dylan

+0

@Dylan Es ist mir ein Vergnügen! Wenn dir das wirklich geholfen hat, akzeptiere bitte meine Antwort. –

+0

ja nur 59 Sekunden warten – Dylan

0

Versuchen Sie es: -

html { 
    height: 100%; 
} 
body { 
    min-height: 100%; 
} 
+0

das funktioniert, aber die Fußzeile ist nicht mehr am unteren Rand. aber danke! – Dylan

0

haben Sie versucht, eine Seite-Wrapper hinzufügen? so etwas wie diese

<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%; 
} 
0

100% Höhe auszukommen Körper HTML müssen zunächst 100% Höhe hat, zuerst Ihre HTML Höhe 100% Stellen;

html { 
     height:100%; 
} 

Dann wird der Körper:

body { 
height:100%; 
} 

schließlich Element Sie wollen 100% heigh sein

nav { 
height:100%; 
} 
+0

ja, html und body sind bereits 100% – Dylan

0

machen das 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>

+0

danke aber Saurav Rastogi gab bereits diese Antwort. – Dylan