以下是使用CSS Flexbox创建一个简单Header的示例代码:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Simple Header</title>
<style>
  .header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    background-color: #333;
    color: #fff;
  }
  .header a {
    color: #fff;
    text-decoration: none;
  }
  .header a:hover {
    text-decoration: underline;
  }
  .logo {
    font-size: 20px;
    font-weight: bold;
  }
  .nav {
    display: flex;
    gap: 20px;
  }
  .nav a {
    padding: 5px 10px;
    background-color: #555;
    border-radius: 5px;
  }
  .nav a:hover {
    background-color: #777;
  }
</style>
</head>
<body>
 
<div class="header">
  <div class="logo">
    <a href="/">My Website</a>
  </div>
  <nav class="nav">
    <a href="/">Home</a>
    <a href="/about">About</a>
    <a href="/contact">Contact</a>
  </nav>
</div>
 
</body>
</html>这段代码创建了一个具有logo、导航链接的Header,使用Flexbox布局实现了Header内部元素的灵活排列和居中对齐。