CSS to make HTML page footer stay at bottom of the page with a minimum height, but not overlap the page

前端 未结 29 2980
悲哀的现实
悲哀的现实 2020-11-21 23:48

I have the following page (deadlink: http://www.workingstorage.com/Sample.htm ) that has a footer which I can\'t make sit at the bottom of the page.

I wa

29条回答
  •  Happy的楠姐
    2020-11-22 00:23

    A simple solution that i use, works from IE8+

    Give min-height:100% on html so that if content is less then still page takes full view-port height and footer sticks at bottom of page. When content increases the footer shifts down with content and keep sticking to bottom.

    JS fiddle working Demo: http://jsfiddle.net/3L3h64qo/2/

    Css

    html{
      position:relative; 
      min-height: 100%;
    }
    /*Normalize html and body elements,this style is just good to have*/
    html,body{
      margin:0;
      padding:0;
    }
    .pageContentWrapper{
      margin-bottom:100px;/* Height of footer*/
    } 
    .footer{
        position: absolute;
        bottom: 0;
        left: 0;
        right: 0;
        height:100px;
        background:#ccc;
    }
    

    Html

       
        
            

提交回复
热议问题