Here's the transition:
.subcont {
width: 250px;
height: 180px;
background: purple;
}
.border1 {
position: absolute;
width: 5px;
height: 0;
margin-left: 250px;
margin-top: -5px;
background: red;
transition-delay: 0;
transition-duration: 0.3s;
}
.border2 {
position: absolute;
width: 0px;
height: 5px;
margin-left: 250px;
margin-top: 180px;
background: red;
transition-delay: 0.3s;
transition-duration: 0.3s;
}
.border3 {
position: absolute;
width: 5px;
height: 0;
margin-left: -5px;
margin-top: 180px;
background: red;
transition-delay: 0.6s;
transition-duration: 0.3s;
}
.border4 {
position: absolute;
width: 0;
height: 5px;
margin-left: -5px;
margin-top: -5px;
background: red;
transition-delay: 0.9s;
transition-duration: 0.3s;
}
.subcont:hover>.border1 {
height: 190px;
}
.subcont:hover>.border2 {
width: 255px;
margin-left: -5px;
}
.subcont:hover>.border3 {
height: 190px;
margin-top: -5px;
}
.subcont:hover>.border4 {
width: 255px;
}
<div class="subcont">
<div class="border1"></div>
<div class="border2"></div>
<div class="border3"></div>
<div class="border4"></div>
</div>
As you can see, it changes the position and size of certain divs to cause a border to appear in the .subcont div; What I would like to know is: how to create a reverse effect to this? I mean, when the user hover in the div .subcont this effect occurs, but how do you do that, the moment the user takes the mouse from above the .subcont div, that effect reverts (disappear first the border4 div, then the border3 , etc.)?