<div class="container">
<div class="ball"></div>
</div>
<div class="actions">
<button id="play">Play</button>
</div>
@import url("https://fonts.googleapis.com/css?family=Gochi+Hand");
* {
box-sizing: border-box;
margin: 0;
padding: 0;
}
body {
width: 100vw;
min-height: 100vh;
margin: 0;
background-color: #291642;
font-family: "Gochi Hand", sans-serif;
font-size: 100%;
letter-spacing: 0.1rem;
color: #fff;
display: flex;
flex-direction: column;
align-items: center;
background: linear-gradient(to right, #44ea76 0%, #39fad7 80%, #39fad7 100%)
no-repeat,
url("https://s3-us-west-2.amazonaws.com/s.cdpn.io/142996/slider-2.jpg")
no-repeat fixed;
background-size: cover;
background-blend-mode: hue;
}
.container {
flex: 1;
min-height: 0;
width: 100%;
display: flex;
align-items: center;
justify-content: center;
position: relative;
}
.actions {
padding: 3vh;
display: flex;
justify-content: center;
align-items: center;
background-color: rgba(0, 0, 0, 0.5);
width: 100%;
}
button {
display: inline-flex;
align-items: center;
font-size: 1.2rem;
height: 3rem;
padding: 0.2rem 3.2rem;
color: rgba(255, 255, 255, 0.8);
background: #ff3366;
border-radius: 10rem;
border: none;
cursor: pointer;
margin: 0 2vh;
transition: all 1s ease-in;
transform-origin: center;
}
button:hover {
box-shadow: inset 0 0 3px 5px currentColor;
transform: rotate(2deg) skew(1deg, -1deg);
}
.ball {
position: absolute;
height: 80px;
width: 80px;
border-radius: 50%;
background: url("https://lh6.googleusercontent.com/-EHKsMyJ4Odg/VInMm3ZiLDI/AAAAAAAAAN0/AELrJLAfABU/s555-no/tao-hieu-ung-qua-bong-lan-bang-css3-animation.png")
no-repeat center;
background-size: cover;
box-shadow: inset -10px -10px 10px rgba(0, 0, 0, 0.6);
margin: auto;
}
View Compiled
const handlePlay = document.getElementById("play");
const tl = gsap.timeline();
handlePlay.addEventListener("click", () => {
tl.to(".ball", {
duration: 1.5,
x: 200,
scale: 2
}).to(".ball", {
duration: 1.5,
x: 0,
scale: 1
});
});
View Compiled
This Pen doesn't use any external CSS resources.