gpt4 book ai didi

html - Bootstrap 4个高度相同的嵌套行

转载 作者:行者123 更新时间:2023-11-28 19:24:48 24 4
gpt4 key购买 nike

认为这个要求很简单:结果应该是一个非常基本的着陆页,其中包含两个主题。每个主题都有一个子主题。在移动设备上,应该只有一列连续包含 Topic1、Subtopic1、Topic2、Subtopic2。在桌面上,主题应并排显示,子主题应垂直对齐。

<div class="container-fluid">

<!-- Subtitles are on the same height but the order on mobile is wrong -->
<div class="row">
<div class="col-md-6">
<h1>Topic 1</h1>
<p>Four lines of text<br>Line2<br>Line3<br>Line4</p>
</div>
<div class="col-md-6">
<h1>Topic 2</h1>
<p>Two lines of text<br>Line2</p>
</div>
</div>

<div class="row">
<div class="col-md-6">
<h2>Subtopic 1</h2>
<p>Number of lines<br>do not matter</p>
</div>
<div class="col-md-6">
<h2>Subtopic 2</h2>
<p>But Subtopic 1 and Subtopic 2 should be<br>vertically aligned while >=md<br>and when <md, Subtopic 1 shold be below Topic 1, not below Topic 2</p>
</div>
</div>

<hr>

<!-- Display on mobile is correct but subtitles on desktop are not aligned anymore -->
<div class="row">
<div class="col-md-6">
<h1>Topic 1</h1>
<p>Four lines of text<br>Line2<br>Line3<br>Line4</p>
<div class="row">
<div class="col">
<h2>Subtopic 1</h2>
<p>Number of lines<br>do not matter</p>
</div>
</div>
</div>
<div class="col-md-6">
<h1>Topic 2</h1>
<p>Two lines of text<br>Line2</p>
<div class="row">
<div class="col">
<h2>Subtopic 2</h2>
<p>But Subtopic 1 and Subtopic 2 should be<br>vertically aligned while >=sm<br>and when <sm, Subtopic 1 shold be below Topic 1, not below Topic 2</p>
</div>
</div>
</div>
</div>

</div>

我很惊讶我不知道如何解决这个问题。非常感谢任何提示。

最佳答案

一种方法是使用来自 Bootstrap 的 order 实用程序类并调整所有元素的标记以使其处于同一级别:

<div class="container-fluid">
<div class="row">
<div class="order-0 order-md-0 col-md-6">
<h1>Topic 1</h1>
<p>Four lines of text<br>Line2<br>Line3<br>Line4</p>
</div>
<div class="order-2 order-md-1 col-md-6">
<h1>Topic 2</h1>
<p>Two lines of text<br>Line2</p>
</div>
<div class="order-1 order-md-2 col-md-6">
<h2>Subtopic 1</h2>
<p>Number of lines<br>do not matter</p>
</div>
<div class="order-3 order-md-3 col-md-6">
<h2>Subtopic 2</h2>
<p>But Subtopic 1 and Subtopic 2 should be<br>vertically aligned while &gt;=md<br>and when &lt;md, Subtopic 1
shold be below Topic 1, not below Topic 2</p> </div> </div> <hr>
</div>
</div>
</div>

查看文档 here .

另一种方法是为您的主题列设置预定义的固定高度,或者获取最高主题高度并在页面加载和窗口调整大小时使用 JavaScript 将其设置为所有其他高度。

关于html - Bootstrap 4个高度相同的嵌套行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56515441/

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