gpt4 book ai didi

html - 为什么 flex-direction 列在这里不起作用?

转载 作者:太空宇宙 更新时间:2023-11-04 01:17:32 25 4
gpt4 key购买 nike

我试图让我的输入相互堆叠以用于移动 View ,但 flex-direction:column; 似乎无法解决问题。

.sign-up{
display:flex;
justify-content: center;
align-items: center;
}

.sign-up-wrap{
display:flex;
justify-content: center;
align-items: center;
}

@media (max-width: 655px){
input[type=text], input[type=email], .btn {
flex-direction: column;
}
}
<div class="sign-up-wrap">
<div class="sign-up">
<input type="text" placeholder="What's your name?"/>
<input type="email" placeholder="What's your email?"/>
</div>
</div>

最佳答案

flex-direction: column; 必须应用于 flex 容器(即 .sign-up),而不是 flex 元素本身。

(我在代码段中将媒体查询更改为 800px min 以立即显示结果)

.sign-up{
display:flex;
justify-content: center;
align-items: center;
}

.sign-up-wrap{
display:flex;
justify-content: center;
align-items: center;
}

@media (max-width: 800px){
.sign-up {
flex-direction: column;
}
}
<div class="sign-up-wrap">
<div class="sign-up">
<input type="text" placeholder="What's your name?"/>
<input type="email" placeholder="What's your email?"/>
</div>
</div>

关于html - 为什么 flex-direction 列在这里不起作用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49821514/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com