css 谁能解释一下为什么间隔不适用?[副本]

tjrkku2a  于 2023-05-19  发布在  其他
关注(0)|答案(1)|浏览(104)

此问题已在此处有答案

In CSS Flexbox, why are there no "justify-items" and "justify-self" properties?(6个回答)
3天前关闭。
有人知道为什么间隔空间不起作用吗?我试图检查它,但提示说,我不应该使用flex-wrap?但我没有。感谢您的任何建议enter image description here

* {
  margin: 0;
  padding: 0;
  font-family: "Poppins", sans-serif;
  box-sizing: border-box;
}

body {
  background: #000;
  color: #fff;
}

.header {
  width: 100%;
  height: 100vh;
  background-image: linear-gradient(rgba(0, 0, 0, 0.7), rgba(0, 0, 0, 0.7)),
    url(/images/header-image.png);
  background-size: cover;
  padding: 10px 8%;
  position: relative;
}

nav {
  display: flex;
  align-items: center;
  align-content: space-between;
  padding: 10px 0;
}
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <link rel="stylesheet" href="/style.css" />
    <title>Netflix</title>
  </head>
  <body>
    <div class="header">
      <nav>
        <img src="/images/logo.png" class="logo" alt="logo" />
        <button>English</button>
        <button>Sign In</button>
      </nav>
    </div>
  </body>
</html>
km0tfn4u

km0tfn4u1#

使用justify-content代替align-content,如下所示:

* {
  margin: 0;
  padding: 0;
  font-family: "Poppins", sans-serif;
  box-sizing: border-box;
}

body {
  background: #000;
  color: #fff;
}

.header {
  width: 100%;
  height: 100vh;
  background-image: linear-gradient(rgba(0, 0, 0, 0.7), rgba(0, 0, 0, 0.7)),
    url(/images/header-image.png);
  background-size: cover;
  padding: 10px 8%;
  position: relative;
}

nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
}
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <link rel="stylesheet" href="/style.css" />
    <title>Netflix</title>
  </head>
  <body>
    <div class="header">
      <nav>
        <img src="/images/logo.png" class="logo" alt="logo" />
        <button>English</button>
        <button>Sign In</button>
      </nav>
    </div>
  </body>
</html>

相关问题