<button class="btn">
<span class="dot"></span>
<span class="dot"></span>
<span class="dot"></span>
<span class="dot"></span>
<span class="dot"></span>
<span class="dot"></span>
<span class="dot"></span>
<span class="dot"></span>
<span class="text">Press Me!</span>
</button>
@import url('https://fonts.googleapis.com/css?family=Montserrat:300,400');
*,
*::before,
*::after {
box-sizing: border-box;
}
:root {
--color-primary-500: #FFEB3B;
--color-primary-600: #FDD835;
--color-primary-900: #F57F17;
--color-secondary-500: #009688;
--color-secondary-900: #004D40;
--font-primary: "Montserrat", sans-serif;
}
html {
font-size: 10px;
}
body {
display: flex;
overflow: hidden;
align-items: center;
justify-content: center;
width: 100vw;
height: 100vh;
background-color: var(--color-secondary-500);
font-family: var(--font-primary);
}
.btn {
position: relative;
display: inline-block;
margin: 0;
padding: 1.5rem 4.5rem;
background: var(--color-primary-500);
color: var(--color-secondary-900);
font-family: inherit;
font-size: 1.4rem;
font-weight: 300;
line-height: normal;
border: 0;
border-radius: 0.4rem;
box-shadow: -1px 1px 8px rgba(0, 0, 0, 0.4);
appearance: none;
cursor: pointer;
transition: background 250ms, box-shadow 250ms;
&:hover {
background: var(--color-primary-600);
box-shadow: -2px 2px 16px rgba(0, 0, 0, 0.6);
}
&:active,
&:focus {
outline: none;
}
&:active {
box-shadow: -4px 4px 24px rgba(0, 0, 0, 0.8);
}
}
.btn .text {
position: relative;
z-index: 2;
}
.btn .dot {
position: absolute;
z-index: -1;
display: block;
width: 200px;
height: 10px;
transform-origin: 5px 5px;
pointer-events: none;
&:nth-child(1) {
top: 50%;
left: 100%;
transform: translate3d(-10px, -5px, 0);
}
&:nth-child(2) {
bottom: 0;
left: 100%;
transform: translate3d(-10px, 0, 0) rotate(45deg);
}
&:nth-child(3) {
bottom: 0;
left: 50%;
transform: translate3d(-5px, 0, 0) rotate(90deg);
}
&:nth-child(4) {
bottom: 0;
left: 0;
transform: rotate(135deg);
}
&:nth-child(5) {
top: 50%;
left: 0;
transform: translate3d(0, -5px, 0) rotate(180deg);
}
&:nth-child(6) {
top: 0;
left: 0;
transform: rotate(225deg);
}
&:nth-child(7) {
top: 0;
left: 50%;
transform: translate3d(-5px, 0, 0) rotate(270deg);
}
&:nth-child(8) {
top: 0;
left: 100%;
transform: translate3d(-10px, 0, 0) rotate(315deg);
}
&::before {
position: absolute;
top: 0;
left: 0;
display: block;
width: 6px;
height: 6px;
background-color: var(--color-primary-500);
border-radius: 50%;
offset-path: path("M0 1c7.1 0 10.7 2 14.3 4s7.1 4 14.3 4 10.7-2 14.3-4 7.2-4 14.3-4 10.7 2 14.3 4 7.1 4 14.3 4 10.7-2 14.3-4 7.1-4 14.3-4 10.7 2 14.3 4 7.1 4 14.3 4 10.7-2 14.3-4 7.1-4 14.3-4 10.7 2 14.3 4 7.1 4 14.3 4");
offset-distance: 0;
pointer-events: none;
content: "";
}
}
.btn.is-animating .dot::before {
animation: dot 750ms cubic-bezier(0.215, 0.61, 0.355, 1);
}
@keyframes dot {
0% {
offset-distance: 0%;
opacity: 1;
}
100% {
offset-distance: 100%;
opacity: 0;
}
}
View Compiled
var $btn = document.querySelector('.btn');
$btn.addEventListener('click', e => {
window.requestAnimationFrame(() => {
$btn.classList.remove('is-animating');
window.requestAnimationFrame(() => {
$btn.classList.add('is-animating');
});
});
});
View Compiled
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.