为什么我的 Flexbox CSS 无法正常运行?
P粉805535434
P粉805535434 2024-02-03 22:23:08
[CSS3讨论组]

为什么 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粉805535434
P粉805535434

全部回复(1)
P粉639667504

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?

热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 意见反馈 讲师合作 广告合作 最新更新
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习
PHP中文网抖音号
发现有趣的

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号