[英]Force Footer to Stay at Bottom of Page With Small Viewport
如果您希望客戶始終在小視口中看到頁腳,請使用position: fixed
,如果您希望僅在小視口中的所有內容的末尾使用頁腳,請使用 css 中的@media
,如下所示:
@media (min-width: 0) and (max-width: 768px){
.footer {
position: relative;
/*bottom: 0px;*/
width: 100%;
}
}
@media (min-width: 768px){
.footer {
position: fixed;
bottom: 0;
left: 0;
height: 200px;
width: 100%;
}
}
如果你想使用position: absolute
check height of .footer
in inspect 並添加height: "num"px;
或使用height: 100%
。
您可以像這樣在@media
中使用min-height and max-height
:
.footer {
position: fixed;
bottom: 0;
left: 0;
height: 200px;
width: 100%;
}
@media (min-height: 650px){
.footer {
position: relative;
/*bottom: 0px;*/
width: 100%;
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.