sticky-footer Posted on 2018-04-21 Edited on 2021-10-11 In 布局 目的实现sticky-footer布局 布局 absolute方案1234567891011121314151617181920212223html,body { padding: 0; margin: 0;}.wrapper { position: relative; min-height: 100vh;}.content { /*100px是footer高度*/ padding-bottom: 100px;}.footer { position: absolute; bottom: 0; width: 100%; height: 100px;} margin方案123456789101112131415161718html,body { padding: 0; margin: 0;}.content { min-height: 100vh; box-sizing: border-box; /*100px是footer高度*/ padding-bottom: 100px;}.footer { height: 100px; /*-100px是-footer高度*/ margin-top: -100px;} flex方案12345678910111213141516171819html,body { padding: 0; margin: 0;}.wrapper { min-height: 100vh; display: flex; flex-flow: column;}.content { flex: 1;}.footer { height: 100px;} calc方案1234567891011121314html,body { padding: 0; margin: 0;}.content { /*100px 是footer高度*/ min-height: calc(100vh - 100px);}.footer { height: 100px;} grid方案1234567891011html, body { margin: 0; padding: 0;}.wrapper { min-height: 100vh; display: grid; /* 100px 为footer高度 */ grid-template-rows: 1fr 100px;}