如何使用 CSS 设置页眉样式?

cssweb developmentfront end technology更新于 2025/12/16 23:08:17

要使用 CSS 设置页眉样式,代码如下: −

示例

<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<style>
   body {
      font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
      margin: 0;
   }
   .header {
      padding: 30px;
      text-align: center;
      background: #bc1a6b;
      color: white;
      font-size: 30px;
   }
   main {
      padding: 20px;
      font-size: 18px;
   }
</style>
</head>
<body>
<div class="header">
<h1>My website ⇅</h1>
</div>
<main>
<h1>Some heading</h1>
<p>Some sample content.Some sample content.</p>
<p>Some sample content.Some sample content.</p>
<p>Some sample content.Some sample content.</p>
</main>
</body>
</html>

输出

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


相关文章


有用资源