How do I place a row of div (which has 3 columns of image) on top of parent div (image) . I am using Bootstrap 5. Previously I used to do postition: absolute
. The problem here is that the row overflow is being hidden. I have tried overflow: visible
too. Below down is the code sample and the result i am getting.
Thank you for any kind of help.
.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>
here are attached images of output:
3
Answers
I’m new to web-development but I think you should try to delete the
top: 0%;
property to see if it makes change.In general, it is better practice to "avoid" position absolute for such a simple layout (position absolute Breaks the normal flow + collapse height). By
negative margin
it is very easy to create this overlap (And keep the normal flow).Snippet (Same as your desire layout solve only by one line of custom CSS):
Just a little changes in the bootstrap structure and shifted the class
accomplishments
fromcontainer-fluid
class tocol-12
class. Also addedmargin-top: 200px !important;
that was missing in your stylesheet.css.accomplishments