英文:
How to get the inner div of the nested div structure into the new line using flex box?
问题
I want the inner div (Mem 3) in the new line, just below Mem 1, and I do not want to change the div structure at any cost. Please help.
.flex-container {
display: flex;
flex-wrap: wrap;
}
.flex-child {
border: solid blue;
}
.flex-fgc {
border: solid blue;
}
.flex-inner-gc {
border: solid blue;
}
I tried 'flex: 1 1 100;' for the flex-inner-gc.
英文:
I want the inner div (Mem 3) in the new line, just below Mem 1, and I do not want to change the div structure at any cost. Please help.
<!-- begin snippet: js hide: false console: true babel: false -->
<!-- language: lang-css -->
.flex-container {
display: flex;
flex-wrap: wrap;
}
.flex-child {
border: solid blue;
}
.flex-fgc {
border: solid blue;
}
.flex-inner-gc {
border: solid blue;
}
<!-- language: lang-html -->
<div class='flex-container'>
<div class='flex-child'>
Mem 1
</div>
<div class='flex-fgc'>
<div>
Mem 2
</div>
<div class='flex-inner-gc'>
Mem 3
</div>
</div>
</div>
<!-- end snippet -->
I tried 'flex: 1 1 100;' for the flex-inner-gc.
答案1
得分: 1
float 可轻松完成这个任务。
<!-- begin snippet: js hide: false console: true babel: false -->
<!-- language: lang-css -->
.flex-child {
border: solid blue;
float: left;
}
.flex-fgc > * {
float: left;
border: solid blue;
}
.flex-inner-gc {
clear: both;
}
<!-- language: lang-html -->
<div class='flex-container'>
<div class='flex-child'>
Mem 1
</div>
<div class='flex-fgc'>
<div>
Mem 2
</div>
<div class='flex-inner-gc'>
Mem 3
</div>
</div>
</div>
<!-- end snippet -->
英文:
float can easily do this.
<!-- begin snippet: js hide: false console: true babel: false -->
<!-- language: lang-css -->
.flex-child {
border: solid blue;
float: left;
}
.flex-fgc > * {
float: left;
border: solid blue;
}
.flex-inner-gc {
clear: both;
}
<!-- language: lang-html -->
<div class='flex-container'>
<div class='flex-child'>
Mem 1
</div>
<div class='flex-fgc'>
<div>
Mem 2
</div>
<div class='flex-inner-gc'>
Mem 3
</div>
</div>
</div>
<!-- end snippet -->
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论