为什么 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>
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
flex auto 0 1是display的无效属性值。您的浏览器的文档检查器将向您显示这一点。您需要在display和flex属性中分隔这些值。我怀疑您还想要
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?