Bootstrap4設置footer固定在底部


參考Bootstrap4官網例子Sticky footer,本文對其做了總結。

1、html標簽

將html顯示高度占滿(class="h-100")。

<html lang="en" class="h-100">

2、body標簽

設置body彈性布局,並將高度占滿(class="d-flex flex-column h-100")。

<body class="d-flex flex-column h-100">

3、main標簽

將main設置為不同的屏幕設備不設置收縮(role="main" class="flex-shrink-0")。

<main role="main" class="flex-shrink-0">

彈性收縮規則:

  • flex-shrink-0 不同的屏幕設備不設置收縮
  • flex-shrink-1 不同的屏幕設備設置收縮

4、footer標簽

設置footer頂部邊框高度自動設置(class="mt-auto")。

<footer class="footer mt-auto py-3">


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM