css - Bootstrap 4 - 将行向上移动

标签 css bootstrap-4

我一直在查看 Bootstrap 文档,但我似乎找不到实现特定效果所需的类。如果父行有一个将底部 div 向下推的列,是否有办法移动/偏移 div 行?这有可能通过 Bootstrap 实现吗?我附上了我要完成的工作的图像以及代码。

What I'm trying to do

<div class="container">
<div class="row">
    <div class="col-sm-5" style="color: white; background:black; height: 100px">Something</div>
    <div class="col-sm-7" style="color: white; background:red; height: 300px">something</div>
</div>
<div class="row">
    <div class="col-sm-5" style="color: white; background:blue; height: 300px; position: top">something</div>
</div>

最佳答案

Bootstrap 4 .row 是 flexbox,所以所有的 col-* 都是最高列的高度。因此,您需要 float- sm 及以上的列...

https://www.codeply.com/go/CuWAXOF6Gs

<div class="container">
    <div class="row d-sm-block">
        <div class="col-sm-5 float-left" style="color: white; background:black; height: 100px">something</div>
        <div class="col-sm-7 float-right" style="color: white; background:red; height: 300px">something</div>
        <div class="col-sm-5 float-left" style="color: white; background:blue; height: 300px; position: top">something</div>
    </div>
</div>
  • d-sm-block 使 display:block 行代替 display:flex 在 sm 及以上
  • float-leftfloat-right 将较高的列拉到右边。

相关:Empty vertical space between columns in Bootstrap 4

关于css - Bootstrap 4 - 将行向上移动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50262922/

相关文章:

html - 与相对和绝对定位对齐

html - 背景图像 :url needs fixed width here, 我该如何更改它?

css - 具有透明背景和渐变边框的圆 Angular 矩形

javascript - 无法使用 javascript 将标签内部的值递增 1

javascript - MDB轮播幻灯片更改事件

javascript - 强制 <table> 列为固定宽度;防止自动展开

html - :before and :after pseudo-elements exhibiting confusing behavior

html - 如何在 flexbox flex-column 类 div 中设置高于 100% 的高度?

javascript - 使用 require.js 加载时在 bootstrap 4 中加载 popper.js 时出错

html - 如何在大屏幕上不同的小屏幕上获得所需的 html 布局