1

I wanted to expand my div all the way from top to bottom even thought I don't have enough elements inside my div.

I have set CSS like

#content{
    margin-top: 10px;
    padding: 15px;
    display:block;
    height:100%
    background-color:red;
}

my html

<div id='content'>
    just a little bit of contents here.
</div>

I want to see the red background all the way from top to bottom of the page.

How can I do this?

Thanks a lot

FlyingCat
  • 13,696
  • 36
  • 114
  • 188

3 Answers3

2

You can make it work by adding this CSS code:

html, body {
    height: 100%;
}

jsFiddle demo.

Ry-
  • 209,133
  • 54
  • 439
  • 449
display-name-is-missing
  • 4,816
  • 5
  • 26
  • 41
2
#content {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    right: 0;
    background-color: red;
}
TheBokiya
  • 610
  • 6
  • 20
0

Add this to your content div, works a treat!

height: 100vh;
user3479267
  • 193
  • 9
  • 29