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

前端 未结 29 2511
悲哀的现实
悲哀的现实 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条回答
  •  误落风尘
    2020-11-22 00:16

    Some solutions didn't work for me but the best option I found was the example below when i decided to use the flex option.

    html, body{
        height: 100%;   
    }
    
    body{
        display: flex;
        flex-direction: column;
    }
    
    .main-contents{ 
        flex: 1 0 auto;
        min-height: 100%;
        margin-bottom: -77px;
      background-color: #CCC;
    }
    
    .footer{
        height:  77px;
        min-height: 77px;
        width: 100%;
        bottom: 0;
        left: 0;
        background: #000000;
        flex-shrink: 0;
        flex-direction: row;
        position: relative;
        
        
    }
    
    .footer-text{
      color: #FFF;
    }
    
    @media screen and (max-width: 767px){
        #content{
            padding-bottom: 0;
        }
        .footer{
            position: relative;
            /*position: absolute;*/
            height: 77px;
            width: 100%;
            bottom: 0;
            left: 0;
        }
    
    }
    
      
        
    this is the main content

提交回复
热议问题