【发布时间】:2022-12-20 06:27:37
【问题描述】:
我正在使用 Bootstrap 5.2。
这个想法是在一行中创建两列,它们都是 col-md-6。此图像是布局外观的一般概念:https://prnt.sc/FaIB3CZMJrO_。
我遇到的问题是我无法创建另一行,其中包含 col-md-6 元素以直接适合 ExampleTitle 列。这是最终发生的事情:https://prnt.sc/YZtp1MJqjQMD。
这就是我想要做的,但在图像中,这样更容易理解:https://prnt.sc/i7w4jVN38uz5。
作为参考,这是我遇到的设计理念(你必须向下滚动一点):https://css-tricks.com/snippets/css/complete-guide-grid/
.card2 {
background: #2b2b2b;
padding: 1rem 1.5rem;
margin-bottom: 25px;
border-radius: 16px;
}
body {
background-color: #131313;
}
h1, h2, h3, h4, h5, h6, a, p {
color: #fff;
}
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/js/bootstrap.bundle.min.js"></script>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container text-center">
<div class="row">
<div class="col-md-6">
<h2>ExampleTitle</h2>
<div class="card2">
<h4>ExampleItem1</h4>
<p>Description</p>
</div>
<div class="card2">
<h4>ExampleItem2</h4>
<p>Description</p>
</div>
<div class="card2">
<h4>ExampleItem3</h4>
<p>Description</p>
</div>
</div>
<div class="col-md-6">
<h2>ExampleTitle2</h2>
<div class="card2">
<h4>Service1</h4>
<p>Something</p>
</div>
<div class="card2">
<h4>Service2</h4>
<p>Something that is a longer sentence and will occupy a new line so that they arent the exact same heights</p>
</div>
<div class="card2">
<h4>Service3</h4>
<p>Something</p>
</div>
<div class="card2">
<h4>Service4</h4>
<p>Something</p>
</div>
</div>
<div class="col-md-6">
<h2>ExampleTitle2</h2>
<div class="card2">
<h4>Service1</h4>
<p>Something</p>
</div>
<div class="card2">
<h4>Service2</h4>
<p>Something that is a longer sentence and will occupy a new line so that they arent the exact same heights</p>
</div>
<div class="card2">
<h4>Service3</h4>
<p>Something</p>
</div>
<div class="card2">
<h4>Service4</h4>
<p>Something</p>
</div>
</div></div>
</div>
【问题讨论】:
-
添加你所拥有的代码
-
我在原始帖子中添加了 HTML 和 CSS,但它不会显示两列,因为它呈现的内容不够大,无法显示两列。
-
不用担心,当点击
Full page时,它会显示在两列中。
标签: html css bootstrap-5