html - bootstrap 4 中的重叠列

标签 html twitter-bootstrap css bootstrap-4

我有一行,里面有三列,如下所示:

<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">

<section>
  <div class="container">
    <div class="row">
      <div class="col-4">
        <img class="img-fluid" src="https://via.placeholder.com/321x620" alt="" />
      </div>
      <div class="col-4">
        <img class="img-fluid" src="https://via.placeholder.com/321x620" alt="" />
      </div>
      <div class="col-4">
        <img class="img-fluid" src="https://via.placeholder.com/321x620" alt="" />
      </div>
    </div>
  </div>
</section>

<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js" integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js" integrity="sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy" crossorigin="anonymous"></script>

我希望这三列重叠并产生如下幻觉:

enter image description here

每个瓶子代表我在上面的代码片段中拥有的每个图像。

感谢您的帮助

注意 中间的图片应该看起来在前面并且比后面的其他两个图片大(完全如图所示)

最佳答案

如果你想一直重叠,而不是使用网格,你可以使用负边距:

.bottle {
  width: 100px;
  height: auto;
  border: 1px solid black;
}

.bottles .bottle:first-child {
  margin-right: -30px;
}

.bottles .bottle:last-child {
  position: relative;
  margin-left: -30px;
  z-index: -1;
}
<div class="bottles">
  <img class="bottle" src="https://via.placeholder.com/321x620">
  <img class="bottle" src="https://via.placeholder.com/321x620">
  <img class="bottle" src="https://via.placeholder.com/321x620">
</div>

我调整了图像大小以适合片段预览,但您只需使用负边距即可获得您想要的效果。

关于html - bootstrap 4 中的重叠列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52009312/

相关文章:

html - 无需调整 Logo 大小的粘性顶部导航栏

html - 如何从wordpress中的移动版本中删除标题栏

php - 选择国家和城市

firefox - Bootstrap glyphicons Firefox 问题

javascript - 动态定位 Bootstrap 工具提示(用于动态生成的元素)

css - IE 8 不获取 CSS

javascript - 在导航中突出显示链接

html - 带有文本的 SVG 周围的 IE/Edge 链接移动文本

html - 如何并排添加两个由图像组成的按钮?

javascript - 向导表单验证