如何使用 CSS 创建固定/粘性页脚?

cssweb developmentfront end technology更新于 2025/11/28 7:08:17

要使用 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>

输出

上述代码将产生以下输出 −


相关文章


有用资源