How to make flex items overlap

Viewed 44

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 class="bg-black">
    <div class="flex flex-col items-center md:flex-row md:justify-center gap-0">
        <div
            class="w-80 h-52 bg-black border-white border-2 border-opacity-30 rounded-lg flex flex-col justify-center items-center gap-4">
        </div>
        <div
            class="w-24 h-24 font-bold rounded-full text-white border-white border-2 border-opacity-30 flex items-center justify-center">
            OR</div>
        <div
            class="w-80 h-52 bg-black border-white border-2 border-opacity-30 rounded-lg flex flex-col justify-center items-center gap-4">
        </div>
    </div>
</body>


2 Answers

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.

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 class="box">
<div class="box1">
</div>
<div class="box2">
  
</div>
<div class="or">
OR
</div>
</div>
</body>

Related