JSFiddle - React, Tailwind, and code Playground
by luka kupunia
HTML
<div class="body">
<div class="box-1">
<div class="box"></div>
</div>
<div class="box-2">
<div class="box"></div>
</div>
</div>
CSS
body {
margin: 0;
}
* {
box-sizing: border-box;
}
div.body:after {
content: '';
display: table;
clear: both;
}
div.box-1 {
width: 60%;
position: relative;
float:left;
background: purple;
padding-top: 30%;
animation: one 1s forwards;
z-index: 2;
}
div.box-1 div.box {
width: 300px;
height: 50px;
background: white;
position: absolute;
top: 50%;
left: 50%;
transform: translate(50%,-50%);
z-index: 2;
}
div.box-2 {
width: 40%;
position: relative;
float:left;
background: brown;
padding-top: 30%;
}
div.box-2 div.box {
width: 300px;
height: 50px;
/* background: black; */
position: absolute;
top: 50%;
left: 50%;
transform: translate(-120%,-50%);
}
@keyframes one {
from {
-webkit-clip-path: polygon(0 0, 0 0, 0 100%, 0% 100%);
clip-path: polygon(0 0, 0 0, 0 100%, 0% 100%);
}
to {
-webkit-clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%);
clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%);
}
}