英文:
How can I nest Bootstrap grid properly without wrapping columns?
问题
I want to make a grid of 8 cols left and 4 columns right. In the 4 columns on the right, I wish to further split it into 4 cols and 8 cols. It is important that the grid does not wrap.
This is my HTML:
<div class="container">
<div class="row">
<div class="col-sm-8 col-md-8">
A
</div>
<div class="col-sm-4 col-md-4">
<div class="col-sm-4 col-md-4">
B
</div>
<div class="col-sm-8 col-md-8">
C
</div>
</div>
</div>
</div>
Unfortunately, C displays under B, which I do not want. How is it possible to stop the grid wrapping underneath, please?
英文:
I want to make a grid of 8 cols left and 4 columns right. In the 4 columns in the right, I wish to further split it up to 4 cols and 8 cols. It is important that the grid does not wrap.
This is my html:
<div class="container">
<div class="row">
<div class="col-sm-8 col-md-8">
A
</div>
<div class="col-sm-4 col-md-4">
<div class="col-sm-4 col-md-4">
B
</div>
<div class="col-sm-8 col-md-8">
C
</div>
</div>
</div>
</div>
unfortunately, C displays under B which I do not want. How is it possible to stop the grid wrapping underneath, please?
答案1
得分: 3
你只需要为嵌套的列使用另一个row
容器。
<!-- begin snippet: js hide: false console: true babel: false -->
<!-- language: lang-css -->
div {
border: 1px solid black;
}
<!-- language: lang-html -->
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css" rel="stylesheet">
<div class="container">
<div class="row">
<div class="col-sm-8 col-md-8">
A
</div>
<div class="col-sm-4 col-md-4">
<div class="row">
<div class="col-sm-4 col-md-4">
B
</div>
<div class="col-sm-8 col-md-8">
C
</div>
</div>
</div>
</div>
</div>
<!-- end snippet -->
英文:
You just need to use another row
container for the nested column.
<!-- begin snippet: js hide: false console: true babel: false -->
<!-- language: lang-css -->
div {
border: 1px solid black;
}
<!-- language: lang-html -->
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css" rel="stylesheet">
<div class="container">
<div class="row">
<div class="col-sm-8 col-md-8">
A
</div>
<div class="col-sm-4 col-md-4">
<div class="row">
<div class="col-sm-4 col-md-4">
B
</div>
<div class="col-sm-8 col-md-8">
C
</div>
</div>
</div>
</div>
</div>
<!-- end snippet -->
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论