JSFiddle - React, Tailwind, and code Playground
by cchana
HTML
<div class="margin">
<div class="box">
<div class="padding">
</div>
</div>
</div>
CSS
body {
background-color: #FFF;
}
.box {
background: #FFF;
height: 200px;
width: 200px;
position: relative;
}
.box:before,
.box:after {
content: '';
height: 200px;
width: 200px;
border-style: dashed;
border-color: #000;
position: absolute; animation-timing-function: linear;
}
.box:before {
border-width: 1px 0 0 1px;
left: 0;
bottom: 0;
animation: drawBox1 2s;
}
.box:after {
border-width: 0 1px 1px 0;
right: -1px;
top: 1px;
animation: drawBox2 4s;
}
.margin {
background-color: #DFD;
padding: 50px;
display: inline-block;
animation: drawMargin 6s;
}
.padding {
box-sizing: border-box;
height: 100%;
width: 100%;
border: 50px solid #FDD;
animation: drawPadding 6s;
}
@keyframes drawBox1 {
0% { height: 0px; width: 0px; }
50% { height: 200px; width: 0px; }
100% { height: 200px; width: 200px; }
}
@keyframes drawBox2 {
0% { height: 0px; width: 0px; }
50% { height: 0px; width: 0px; }
75% { height: 200px; width: 0px; }
100% { height: 200px; width: 200px; }
}
@keyframes drawMargin {
0% { margin: 50px; padding: 0; }
70% { margin: 50px; padding: 0; }
100% { margin: 0px; padding: 50px; }
}
@keyframes drawPadding {
0% { border-width: 0; }
70% { border-width: 0; }
100% { border-width: 50px; }
}