I have this flex container which has three circles and I want the first one to have a bite effect on the right, the middle one normal and the last circle a bite on the left.
I tried putting another circle on top of another and just adding margin to it but it doesn’t work for the third circle. Any idea how I can do this?
.container {
display: flex;
flex-direction: row;
gap: 20px;
position: relative;
width: 100%;
}
.box1 {
width: 300px;
height: 300px;
background-color: blue;
border-radius: 50%;
z-index: 10;
}
.add-edge-right {
margin-left: 250px;
background-color: white;
}
.add-edge-left {
margin-right: 250px;
background-color: white;
}
<div class="container">
<div class="box1">
<div class="box1 add-edge-right"></div>
</div>
<div class="box1"></div>
<div class="box1">
<div class="box1 add-edge-left"></div>
</div>
</div>
Screenshot:
2
Answers
I would suggest another way than flex.
old school one with relative, absolute position and border
(don’t forget the box-sizing otherwise it’s not working)
If you want to change the size, for exemple container from 600 to 900:
we’ll put border to 50px, so 50 each side -> width, height 400px
top -50px (height of the border)
If you want the ‘bite’ to be transparent, for example so a background shows through, then you can use CSS mask.
In this snippet the width of the elements has been set at a CSS variable so you can easily change it if required as is the amount you want the bite ‘offset’ – to make it bigger or smaller.