Say I have these two div’s
.el-2 {
position: absolute;
left: 40px;
top: 20px;
}
div {
border: 1px solid black;
width: 50px;
height: 25px;
}
<div class="el-1">
</div>
<div class="el-2">
</div>
How can I make them look like this?
Doesn’t matter if we somehow merge them together or use SVGs but I need the background to stay transparent
3
Answers
There’s a workaround for this, which is using
::before
Selector. gonna make a white square which will cover the lines of intersection twodivs
:You can approximate it using a drop-shadow on a parent element
The problem with the methods suggested which involve an overlay is that the part we want to get rid of is not an exact rectangle. There is a bit in the internal corners which must remain.
This snippet takes a different approach. It uses mix-blend-mode to choose the lighter of the two colors within each div. This gets rid of the black border that lies within it.
To ensure that the blending doesn’t also involve any other background the divs are put within a container which is isolated (new staking context).
Note: as with the other methods suggested this means the rectangles have white rather than transparent backgrounds.