Flexbox行不显示DIV
我的Flexbox不是将两个Divs显示为列,而是在另一列下方显示。不确定为什么我有显示:flex
和flex方向:行
。
app.js文件:
import logo from "./logo.svg";
import "./App.css";
function App() {
return (
<div className="App">
<div className="innerBox">
<div className="innerBoxContent">
<div className="menu">
<h1>Menu</h1>
</div>
<div className="content">
<h1>content</h1>
</div>
</div>
</div>
</div>
);
}
export default App;
CSS文件:
.App {
background-color: rgb(24, 24, 35);
height: 100vh;
width: 100vw;
display: flex;
}
.innerBox{
width: 600px;
height: 600px;
background-color: red;
margin: auto;
display: flex;
flex-direction: row;
}
.menu{
background-color: blue;
height: 600px;
width: 300px;
}
.content
{
background-color: orange;
height: 600px;
width: 300px;
}
有人可以解释为什么它不按预期工作。谢谢。
My Flexbox is not displaying two divs as columns but one underneth the other. Not sure why as I have display: flex
and flex-direction: row
.
App.js file:
import logo from "./logo.svg";
import "./App.css";
function App() {
return (
<div className="App">
<div className="innerBox">
<div className="innerBoxContent">
<div className="menu">
<h1>Menu</h1>
</div>
<div className="content">
<h1>content</h1>
</div>
</div>
</div>
</div>
);
}
export default App;
CSS file:
.App {
background-color: rgb(24, 24, 35);
height: 100vh;
width: 100vw;
display: flex;
}
.innerBox{
width: 600px;
height: 600px;
background-color: red;
margin: auto;
display: flex;
flex-direction: row;
}
.menu{
background-color: blue;
height: 600px;
width: 300px;
}
.content
{
background-color: orange;
height: 600px;
width: 300px;
}
Can someone explain why its not working as intended. Thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
“”
应在将flex-box应用于它时删除,而不是其内容
修复的HTML文件应该看起来像这样
""
Should be removed as the flex-box is being applied to it and not its contents
Fix for HTML file should look like this
CSS属性
Flex-wrap:Nowrap;
应添加到具有类名称.innerbox
的容器中。CSS property
flex-wrap: nowrap;
should be added to container with class name.innerBox
.您拥有
菜单
和content
组件在内部。InnerContent
block。因此,
.innerboxContent
应该是flex。You have
menu
andcontent
components are inside of.innerContent
block.So
.innerBoxContent
should be flex.