Bootstrap fixed header and footer with scrolling body-content area in fluid-container

后端 未结 3 1345

I was surprised I could not find a simple answer to this problem by Googling, but most responses to scrolling content panels either did not work properly, or did not work wi

3条回答
  •  臣服心动
    2020-12-08 02:01

    Another option would be using flexbox.

    While it's not supported by IE8 and IE9, you could consider:

    • Not minding about those old IE versions
    • Providing a fallback
    • Using a polyfill

    Despite some additional browser-specific style prefixing would be necessary for full cross-browser support, you can see the basic usage either on this fiddle and on the following snippet:

    html {
      height: 100%;
    }
    html body {
      height: 100%;
      overflow: hidden;
      display: flex;
      flex-direction: column;
    }
    html body .container-fluid.body-content {
      width: 100%;
      overflow-y: auto;
    }
    header {
        background-color: #4C4;
        min-height: 50px;
        width: 100%;
    }
    footer {
        background-color: #4C4;
        min-height: 30px;
        width: 100%;
    }
    
    
    Lorem Ipsum
    Lorem Ipsum
    Lorem Ipsum
    Lorem Ipsum
    Lorem Ipsum
    Lorem Ipsum
    Lorem Ipsum
    Lorem Ipsum
    Lorem Ipsum
    Lorem Ipsum
    Lorem Ipsum
    Lorem Ipsum
    Lorem Ipsum
    Lorem Ipsum
    Lorem Ipsum
    Lorem Ipsum
    Lorem Ipsum
    Lorem Ipsum
    Lorem Ipsum
    Lorem Ipsum
    Lorem Ipsum
    Lorem Ipsum
    Lorem Ipsum
    Lorem Ipsum
    Lorem Ipsum

提交回复
热议问题