HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Transform</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<h1>Hover on the bat ... </h1>
<div class="field">
<img class="bat" src="img/bat.png">
<div class="ball"> </div>
</div>
</body>
</html>
CSS
h1 {
font-size : 50px;
text-align : center;
font-weight: bolder;
font-family: 'Segoe UI';
}
.field {
border : 5px dotted green;
background-color: rgba(4, 145, 4, 0.2);
width : 85%;
height : 550px;
margin : auto;
padding : 30px;
}
/***************** bat *****************/
.bat {
width : 400px;
height : 400px;
transition : transform .5s ease-in-out;
/* transform-origin: x y */
transform-origin : 100% 0%;
}
.bat:hover {
transform : rotate(-70deg);
transform-origin: 100% 0%;
}
/***************** ball *****************/
.ball {
width : 50px;
height : 50px;
background-color: red;
border-radius : 50%;
position : relative;
left : 610px;
transition : transform 2s ease-in-out .8s;
}
.field:hover .ball {
transform: translate(900px, -300px);
}
Comments
Post a Comment