So I'm trying to create a responsive frame with inverted corners for my website. I achieved to create the shape of it but once I try to add border to it, -webkit-mask cuts it out. Is there any way to achieve this easily?
.box {
width: 98%;
height: 800px;
-webkit-mask: radial-gradient(40px at 40px 40px,#0000 98%,#000) -40px -40px;
background-color: black;
margin: auto;
border-width: 10px;
border-style: solid;
border-color: red;
}
<div class="box">
</div>
Thank you
Create a border frame with inverted corners and transparent background.
Just reverse your thinking. Rather than adding border after the mask is applied, put some red circles in the corners before applying the mask. Create a background with a similar repeating radial gradient to what you’re using for the mask.
Note that by default, the origin of a mask is
border-box
and the origin of a background ispadding-box
. In this case we want these origins to coincide, so we explicitly set the background origin toborder-box
.