CSS Sticky Footers with Unknown Height

前端 未结 7 1527
自闭症患者
自闭症患者 2020-11-30 00:41

Is there any way to stick a footer to the bottom of the browser screen or right after the content (depending on which is longer) using CSS without knowing the size

相关标签:
7条回答
  • 2020-11-30 01:22

    If you're willing to jump into the HTML5 future, you can use flexbox...

    body {
        display: flex;
        min-height: 100vh;
        flex-direction: column;
    }
    
    main {
       flex: 1;
    }
    
    • My more detailed answer to the same question: How to make a fluid sticky footer (full example: http://jsfiddle.net/n5BaR/)

    • Solved by flexbox: http://philipwalton.github.io/solved-by-flexbox/demos/sticky-footer/

    • What is Flexbox from MDN: https://developer.mozilla.org/en-US/docs/Web/Guide/CSS/Flexible_boxes

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