搜索

首页  >  问答  >  正文

为什么我的 Flexbox CSS 无法正常运行?

为什么 display:flex 在我的 CSS 代码中不起作用?我想让我的 HTML 代码的这一部分位于页面的中心。

body {
  margin: 0;
  display: flex auto 0 1;
  justify-content: center;
  height: 100vh;
}
<form class="form" id="form"></form>
<h4 class="score" id="score">score :0</h4>
<h1 id="Question">What is 1 multiply by 1?</h1>
<input type="text" class="input" id="input" placeholder="Enter your answer" autofocus autocomplete="off">
<button type="submit" class="btn">submit</button>

P粉805535434P粉805535434380 天前402

全部回复(1)我来回复

  • P粉639667504

    P粉6396675042024-02-04 20:09:17

    flex auto 0 1display 的无效属性值。您的浏览器的文档检查器将向您显示这一点。您需要在 displayflex 属性中分隔这些值。

    我怀疑您还想要 flex-direction: column,但我会将其留给您。

    body {
      margin: 0;
      display: flex;
      flex: auto 0 1;
      justify-content: center;
      height: 100vh;
    }

    score :0

    What is 1 multiply by 1?

    回复
    0
  • 取消回复