2017-08-11 22 views

回答

2

您可以使用flexbox來實現粘腳。

使用flex: 1 0 auto;section將使其成爲flexible,它將獲得flex-container中的所有可用空閒空間。

flex: <positive-number>

使柔性物品的柔性,並將柔性基礎零, 導致接收 自由空間中的柔性容器中的指定比例的項。如果在柔性容器 使用這種模式的所有項目,它們的大小將正比於指定 柔性factor.Equivalent彎曲:1 0

html, 
 
body { 
 
    margin: 0; 
 
    padding: 0; 
 
} 
 

 
html { 
 
    height: 100%; 
 
} 
 

 
body { 
 
    min-height: 100%; 
 
    display: flex; 
 
    flex-direction: column; 
 
    height: 1px; /* Height hack for IE */ 
 
} 
 

 
header, 
 
footer { 
 
    padding: 10px; 
 
    color: white; 
 
    background-color: #000; 
 
} 
 

 
section { 
 
    flex: 1 0 auto; /* This will make section flexible */ 
 
}
<header>Header</header> 
 
<section></section> 
 
<footer>Footer</footer>

+0

上次我檢查Flexbox的沒Bootstrap效果不佳。那個改變了嗎? – AngryHacker

+0

'flexbox'是網格系統,它也可以使用bootstrap,我已經使用了很多,尤其是'粘性頁腳'或'粘性側邊欄'。 'bootstrap4'正在使用'flexbox'。 –

相關問題