如何使用 CSS 建立固定/粘性頁面頁尾?
要使用 CSS 建立固定頁尾,程式碼如下 −
示例
<!DOCTYPE html> <html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <style> body{ font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; } .footer { font-size: 20px; position: fixed; left: 0; bottom: 0; width: 100%; background-color: rgb(50, 6, 100); color: white; text-align: center; } </style> </head> <body> <h1>Fixed/Sticky Footer Example</h1> <div class="footer"> <p>All rights reserved ©</p> </div> </body> </html>
輸出
以上程式碼將產生如下輸出 −
廣告