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;
width: 100px;
height: 50px;
left: 50%;
top: 50%;
-webkit-transform: translate(-50%, -50%);
background-color: green;
transition: all 0.5s ease;
-webkit-transition: all 0.5s ease;
-moz-transition: all 0.5s ease;
-webkit-animation: to-bottom-right 0.5s 0.5s forwards;
-ms-animation: to-bottom-right 0.5s 0.5s forwards;
-moz-animation: to-bottom-right 0.5s 0.5s forwards;
animation: to-bottom-right 0.5s 0.5s forwards;
}
#click {
width: 100px;
height: 50px;
background-color: cornflowerblue;
color: white;
font-weight: bold;
text-align: center;
}
@-webkit-keyframes to-bottom-right {
100% {
left: 100%;
top: 100%;
-webkit-transform:translate(-100%,-100%);
}
}
@-moz-keyframes to-bottom-right {
100% {
left: 100%;
top: 100%;
-moz-transform:translate(-100%,-100%);
}
}
@-ms-keyframes to-bottom-right {
100% {
left: 100%;
top: 100%;
-ms-transform:translate(-100%,-100%);
}
}
@keyframes to-bottom-right {
100% {
left: 100%;
top: 100%;
transform:translate(-100%,-100%);
}
}