4

I have two columns for my website and right now the background color ends at the last piece of content in the left column (which is for navigation).

I've tried height:100%, min-height:100%; etc. Doesn't seem to work. here's the css.

.container {
    width: 100%;
    height:100%;
    min-width: 960px;
    background: #fbf6f0;
    margin: 0 auto; 
    overflow: hidden;
}

#sidebar1 {
    float: left;
    position:absolute;
    width: 20%;
    height:100%;
    min-width:220px;
    background: none repeat scroll 0% 0% #007cb8;
    z-index:9999;
}
  • set the body and html to a height of 100% as well... – Pevara Apr 11 '13 at 18:33
  • possible duplicate of [For div to extend full height](http://stackoverflow.com/questions/4535983/for-div-to-extend-full-height) – karthikr Apr 11 '13 at 18:36
  • 1
    possible duplicate of [Make div 100% height of browser window](http://stackoverflow.com/questions/1575141/make-div-100-height-of-browser-window) – Yarin Jan 25 '15 at 22:56

4 Answers4

8

Use viewport height - vh.

.container {
height: 100vh;
}

Update

Please note, there are potential issues with using VH on Safari iOS. See this thread for more information: Chrome / Safari not filling 100% height of flex parent

Community
  • 1
  • 1
JSeligsohn
  • 91
  • 1
  • 5
5

Set the body height too

body,html{
  height:100%;
}

div {
  height:100%
}
Kevin Lynch
  • 24,427
  • 3
  • 36
  • 37
0

The reason the div doesn't fill the entire window by default if because it's parent, the <body> tag probably, only stretches as heigh as it needs to. Add this at the top of your stylesheet (I like to order styles in a similar order to that of the tags in the markup):

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

edit: grammar

Blieque
  • 670
  • 7
  • 28
0
overflow-y: auto;

This css code is for your solution.

kero
  • 10,647
  • 5
  • 41
  • 51