我有一個包裝,它需要水平居中。除了使用絕對位置之外,我知道沒有其他方法可以做到。位置絕對包裝後的粘性頁腳
#wrapper {
width: 721px;
height: 720px;
position: absolute;
margin: auto;
top: 136px;
left: 0;
right: 0;
background: white;
clear: both;
}
它包含三個其他的浮動divs。如果我將包裝的位置更改爲相對位置,則這些div會混亂。
____________________________________________
header
____________________________________________
__wrapper____________
| | |
| | |
| div1 | div2 |
| | |
| | |
| | |
|_________|__________|
| div3 |
|____________________|
__________________________________________
footer
__________________________________________
但是我想要一個粘滯的頁腳,它總是在網站的底部。無論我有多少內容,它都會停留在底部。如果我的包裝不是位置:絕對的,我可以實現它,但由於它不能推動頁腳底部,我想知道是否有其他方法可以做到這一點?
.footer {
border-top: 1px solid #dcdcdc;
max-width: 100vw;
font-weight: bold;
text-align: center;
background: #f0f0f0;
width: 100%;
height: 80px;
}
正如您在JS-FIDDLE中看到的,頁腳隱藏在標題後面。
發佈完整的代碼片段 –
@SauravRastogi新增JS-小提琴 – Mirakurun