【发布时间】:2019-01-09 16:29:23
【问题描述】:
我整天都在寻找答案,但还没有找到答案。 使用 Bootstrap 4,如何使用 d-flex 或 flex-wrap 将文本环绕在带有列和行的网格布局中。我提供了我的代码和两个图像示例。我希望这是可能的。 我看过这个例子 - https://www.codeply.com/api/run 但它完全不同,而图像是固定大小的,但我们需要图像是响应式的。 提前干杯和感谢。
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css">
<div class="container" style="margin-top: 30px;">
<div class="row" style="border: 1px solid #ddd;">
<div class="col-sm-6 col-lg-6 col-xl-5">
<div class="imagebox">
<figure>
<img class="rounded img-fluid" src="https://www.bbh.co.nz/hostelImages/hi_2243_gal.jpg" alt="" />
<figcaption class="imagebox-desc">VERANDAHS<br>
<span class="small">Superior Central Location...</span></figcaption>
</figure>
</div>
</div>
<div class="col-sm-6 col-lg-6 col-xl-7">
<div class="row">
<div class="col-12"><small>BPP Rating - 88%</small></div>
<!-- this below line will wrap on all screens -->
<div class="col-6"><small>Online Rating - 88% </small></div>
<div class="col-6 text-right"><small>Total Beds - 50</small></div>
</div>
<hr style="margin: 0.5rem 0;">
<div class="row">
<div class="col-sm-6 col-6"><small>Share Rooms from NZD $30</small></div>
<div class="col-sm-6 col-6 text-right"><small>Private Rooms from NZD $60</small></div>
</div>
<div class="row">
<div class="col-12 d-none d-lg-block d-xl-block">Lorem ipsum dolor sit amet, at assum perpetua dissentiet sit, et sea probatus sententiae ullamcorper, voluptatibus signiferumque ex has. No vel postea scripta alienum, eam te enim feugiat ornatus. Exerci quidam melius has ad. Mel ut ludus choro
instructior. Erat dictas antiopam quo ea, pri at audiam offendit.Cetero albucius pri ne, erant nobis aliquip cu sit, eam dolore.</div>
</div>
</div>
</div>
【问题讨论】:
-
设置图片宽度为100%
-
为了进一步澄清,在 Bootstrap 中,我需要找到一个类,它允许列出的 div 类作为高达 995px 的“行”,然后更改为“列”。
-
感谢@Anjali,但这也不起作用。我过去曾尝试过。这与我认为我布置行和列的方式有关。最后一行需要以某种方式成为 med 屏幕的 flex-row 以允许换行,但不确定这实际上是如何工作的。
-
可以参考this重写
-
@Felicia 您可以手动设置行宽并设置其背景
标签: css flexbox grid bootstrap-4 word-wrap