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
  • 14,036
  • 36
  • 119
  • 198

3 Answers3

2

You can make it work by adding this CSS code:

html, body {
    height: 100%;
}

jsFiddle demo.

Ry-
  • 218,210
  • 55
  • 464
  • 476
display-name-is-missing
  • 4,424
  • 5
  • 28
  • 41
2
#content {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    right: 0;
    background-color: red;
}
TheBokiya
  • 620
  • 6
  • 21
0

Add this to your content div, works a treat!

height: 100vh;
user3479267
  • 202
  • 9
  • 32