<div class="container">
<div class="ball"></div>
</div>
<div class="actions">
<input type="radio" name="yoyo" id="yoyo" />
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" viewBox="0 0 59.29 60.46">
<circle id="outline" cx="29.44" cy="29.72" r="15.05" style="fill:none;stroke:#f36;stroke-miterlimit:10;stroke-width:3px" />
<circle id="center" cx="29.44" cy="29.72" r="9.2" style="fill:#f36;stroke:#f36;stroke-miterlimit:10;stroke-width:2px" />
<g id="lines" style="fill:none;stroke:#f36;stroke-miterlimit:10;stroke-width:4px">
<path d="M.88,31.45h0a15,15,0,0,0,14.92,8,17.74,17.74,0,0,0,13.84-9.78h0" />
<path d="M27.34.88h0a15,15,0,0,0-8,14.92,17.74,17.74,0,0,0,9.78,13.84h0" />
<path d="M58.4,28.52h0a15,15,0,0,0-14.91-8,17.77,17.77,0,0,0-13.85,9.78h0" />
<path d="M32,59.58h0a15,15,0,0,0,7.87-15A17.73,17.73,0,0,0,30,30.83h0" />
<path d="M9.64,52.44h0a15,15,0,0,0,16.19-4.91,17.76,17.76,0,0,0,2.87-16.7h0" />
<path d="M8,10.82H8A15,15,0,0,0,12.94,27a17.73,17.73,0,0,0,16.7,2.87h0" />
<path d="M47.83,9.21h0a15,15,0,0,0-16.18,4.91,17.76,17.76,0,0,0-2.87,16.71h0" />
<path d="M51.46,49.3h0a15,15,0,0,0-4.91-16.18,17.78,17.78,0,0,0-16.71-2.88h0" />
</g>
</svg>
<label for="yoyo">yoyo</label>
</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;
}
label {
font-size: 2rem;
color: #f36;
}
svg {
width: 50px;
height: 50px;
user-select: none;
outline: none;
}
input {
cursor: pointer;
position: absolute;
left: 0;
width: 0;
height: 0;
user-select: none;
outline: none;
}
#lines path {
stroke-dasharray: 10px 46px;
stroke-linecap: round;
stroke-dashoffset: 67px;
}
#center {
transition: r 0.3s ease-in-out;
stroke-width: 0;
r: 0px;
}
input[type="radio"]:checked + svg #lines path {
stroke-dashoffset: 10px;
transition: stroke-dashoffset 0.5s ease-in-out,
stroke-dasharray 0.5s ease-in-out;
}
input[type="radio"]:checked + svg #center {
r: 9.2;
transition-delay: 0.3s;
}
View Compiled
const radioBox = document.getElementById("yoyo");
const tl = gsap.timeline({
repeat: -1,
yoyo: false,
defaults: {
duration: 1.5,
ease: "bounce"
}
});
tl.to(".ball", {
y: 50,
scale: 2
}).to(".ball", {
x: 200,
scale: 2
});
radioBox.addEventListener("click", (etv) => {
tl.yoyo(etv.target.checked);
});
View Compiled
This Pen doesn't use any external CSS resources.