JSFiddle - React, Tailwind, and code Playground
by viphalongpro
HTML
<div id="click">Hover over me!!</div>
<div id="main"></div>
CSS
#main {
position: fixed;
height: 100%;
width: 100%;
left:0;
top:60px;
background-color: red;
transition: all 0.5s ease;
-webkit-transition: all 0.5s ease;
-moz-transition: all 0.5s ease;
}
#click:hover + #main {
position: fixed;
background-color: green;
transition: all 0.5s ease;
-webkit-transition: all 0.5s ease;
-moz-transition: all 0.5s ease;
-webkit-animation: shrink 0.5s forwards;
-ms-animation: shrink 0.5s forwards;
-moz-animation: shrink 0.5s forwards;
animation: shrink 0.5s forwards;
}
#click {
width: 100px;
height: 50px;
background-color: cornflowerblue;
color: white;
font-weight: bold;
text-align: center;
}
@-webkit-keyframes shrink {
50% {
left: 50%;
top: 50%;
width:100px;
height:50px;
-webkit-transform:translate(-50%,-50%);
}
100% {
left:100%;
top:100%;
width:100px;
height:50px;
-webkit-transform:translate(-100%,-100%);
}
}
@-ms-keyframes shrink {
50% {
left: 50%;
top: 50%;
width:100px;
height:50px;
-ms-transform:translate(-50%,-50%);
}
100% {
left:100%;
top:100%;
width:100px;
height:50px;
-ms-transform:translate(-100%,-100%);
}
}
@-moz-keyframes shrink {
50% {
left: 50%;
top: 50%;
width:100px;
height:50px;
-moz-transform:translate(-50%,-50%);
}
100% {
left:100%;
top:100%;
width:100px;
height:50px;
-moz-transform:translate(-100%,-100%);
}
}
@keyframes shrink {
50% {
left: 50%;
top: 50%;
width:100px;
height:50px;
transform:translate(-50%,-50%);
}
100% {
left:100%;
top:100%;
width:100px;
height:50px;
transform:translate(-100%,-100%);
}
}