【发布时间】:2021-06-26 22:31:13
【问题描述】:
如何在父 div (image) 之上放置一行 div(有 3 列图像)。我正在使用 Bootstrap 5。以前我曾经做过postition: absolute。这里的问题是行溢出被隐藏了。我也试过overflow: visible。下面是代码示例和我得到的结果。
感谢您的任何帮助。
.accomplishments{
background: url("https://picsum.photos/1000/600");
width: 100%;
height: 40rem;
background-size: cover;
margin-top: 12rem;
position: relative;
}
.project-tray{
position: absolute;
top: 0%;
left: 50%;
transform: translate(-50%, -50%);
overflow-y:visible ;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.5.0/css/bootstrap.min.css" rel="stylesheet"/>
<main>
<div class="container" >
<h1 class="">Accomplishments</h1>
</div>
<div class="container-fluid accomplishments mb-5 ">
<div class="container" >
<div class="row project-tray ">
<div class="col " >
<img src="https://picsum.photos/300/301" class="img-fluid " alt="">
</div>
<div class="col">
<img src="https://picsum.photos/300/302" class="img-fluid" alt="">
</div>
<div class="col">
<img src="https://picsum.photos/300/303" class="img-fluid" alt="">
</div>
</div>
</div>
</div>
</main>
这里是输出的附加图像:
【问题讨论】:
-
在您的 HTML 中找不到标题为“成就”的容器。也请分享一下。
-
你好 Samir,
<h1>Accomplishments</h1>没有问题。这里的问题是溢出行以某种方式被隐藏了。我已经更新了图片。 -
我明白这一点。但为了给您提供解决方案,我们需要一个合适的、完整的结构。如果你能创建一个小提琴 (jsfiddle.net) 那就最好了。
-
您好 Samir,我已经为该部分添加了适当的代码结构。感谢您指出我的错误。
-
i.stack.imgur.com/K8wIB.png 这是您的预期输出吗?
标签: html css twitter-bootstrap bootstrap-5