div stretch 100% page height regardless of content

前端 未结 3 347
醉酒成梦
醉酒成梦 2021-01-13 09:07

live (work in progress) site

Basically, I have all of my site\'s content centered within a div that is a specified width and an intended height of 100% regardless of

相关标签:
3条回答
  • 2021-01-13 10:01

    You can achieve by 2 ways:

    1) Give Height to 100% if you don't know how long page could be.

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

    2) If you know how much you need to stretch vertically then you can use height in "vh(vertical height)".

    .yourContainerClass{
        height:80vh;
    }
    

    I hope it will help you. Thank you!

    0 讨论(0)
  • 2021-01-13 10:02

    see this jsfiddle

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

    discussing this over here too.....

    proper css to ensure that the body element fills the entire screen

    0 讨论(0)
  • 2021-01-13 10:06

    You can set position:absolute, and that should stretch it to the bottom. Seems as if that will work fine in Opera and Chrome at least.

    That will, however, be in conflict with the video player below, and also push your copyright notice down below the page. Maybe you can move the notice up into the gray box though?

    0 讨论(0)
提交回复
热议问题