Home > database >  How to make flex items overlap
How to make flex items overlap

Time:09-06

My document currently looks like this: https://i.stack.imgur.com/VeUFo.png But I want the circle to overlap the boxes like this: https://i.stack.imgur.com/99I6s.png

How do I do that?

Code:

<body >
    <div >
        <div
            >
        </div>
        <div
            >
            OR</div>
        <div
            >
        </div>
    </div>
</body>


CodePudding user response:

You can try adding negative margins to your "OR" div. Note you will have to increase the z-index too, and set a background colour to achieve the desired result.

You can append these classes to your class attribute:

... -mx-4 z-10 bg-black

You can check the result directly in this Tailwind playground.

CodePudding user response:

You can implement this using "absolute" positioning.

.box{
  display: flex;
  position: relative;
}
.box1{
  margin-right: 10px;
}
.box1, .box2{
  height: 200px;
  flex: 50% 0 0;
  border: 5px solid black;
}
.or{
  position: absolute;
  top: 30%;
  bottom: 50%;
  left: 45%;
  height: 80px;
  width: 80px;
  border-radius: 80px;
  border: 5px solid black;
  background-color: black;
  color: white;
  text-align: center;
  vertical-align: center;
  line-height: 80px;
}
<body>
<div >
<div >
</div>
<div >
  
</div>
<div >
OR
</div>
</div>
</body>

  • Related