*,
*::before,
*::after {
box-sizing: border-box;
}
:root {
font: 2ch/1.5 'RailroadRoman', sans-serif;
}
body {
width: 100%;
height: 100%;
margin: 0;
padding: 0;
background: #000;
overflow-x: hidden;
}
main {
display: flex;
flex-wrap: wrap;
justify-content: space-evenly;
align-items: center;
align-content: center;
gap: 2rem;
width: 100%;
min-height: 100vh;
margin: 0 auto;
background: #000;
}
button {
position: relative;
width: min-content;
width: 5rem;
height: 2rem;
padding-inline: 0.5rem;
border: 2px solid #fff;
border-radius: 8px;
outline-width: 2px;
outline-style: solid;
outline-color: #fff;
outline-offset: 0;
font: inherit;
cursor: pointer;
}
button i {
position: absolute;
top: -0.5em;
right: -0.5em;
z-index: 500;
display: block;
font-style: normal;
font-size: 1.5em;
cursor: pointer;
}
.A.yang:hover {
animation: pulse 600ms cubic-bezier(1.000, 0.000, 0.000, 1.000) both alternate infinite;
}
.A.ying:hover {
animation: pulse 2s cubic-bezier(0.445, 0.050, 0.550, 0.950) infinite;
}
@keyframes pulse {
0% {
box-shadow:
0 0 0 0 rgba(255, 255, 255, 0.7),
0 0 0 0 rgba(255, 255, 255, 0.5),
0 0 0 0 rgba(255, 255, 255, 0.3);
}
50% {
box-shadow:
0 0 0 10px rgba(255, 255, 255, 0),
0 0 0 20px rgba(255, 255, 255, 0),
0 0 0 30px rgba(255, 255, 255, 0);
}
100% {
box-shadow:
0 0 0 30px rgba(255, 255, 255, 0),
0 0 0 40px rgba(255, 255, 255, 0),
0 0 0 50px rgba(255, 255, 255, 0);
}
}
.B::before,
.B::after {
content: "";
position: absolute;
top: 0;
left: 0;
display: block;
width: 5rem;
height: 2rem;
border-radius: 8px;
outline-width: 2px;
outline-style: solid;
outline-color: #fff;
outline-offset: 0;
background: transparent;
}
.B.ying:hover::before {
z-index: 80;
animation: eb 2s ease-in backwards infinite;
}
.B.ying:hover {
z-index: 80;
animation: ripple 2s 2s ease-out both alternate infinite;
}
.B.ying:hover::after {
z-index: 120;
animation: wave 2s ease-out forwards infinite;
}
.B.yang:hover::before {
z-index: 110;
animation: wave 2s 1s ease-out backwards infinite;
}
.B.yang:hover {
z-index: 140;
animation: ripple 2s 2s ease-in-out both alternate infinite;
}
.B.yang:hover::after {
z-index: 130;
animation: eb 2s ease-out backwards infinite;
}
@keyframes ripple {
0% {
outline-width: 2px;
outline-color: transparent;
outline-offset: 0;
}
50% {
outline-width: 2px;
outline-color: #fff;
outline-offset: 30px;
}
70% {
outline-width: 2px;
outline-color: rgba(255, 55, 0 0.5);
outline-offset: 50px;
}
100% {
outline-width: 1px;
outline-color: transparent;
outline-offset: 0;
}
}
@keyframes wave {
0% {
outline-width: 1px;
outline-color: #fff;
outline-offset: 40px;
}
20% {
outline-width: 2px;
outline-color: rgba(255, 255, 10, 0.6);
outline-offset: 30px;
}
70% {
outline-width: 1px;
outline-color: rgba(255, 200, 5 0.3);
outline-offset: 10px;
}
100% {
outline-width: 1px;
outline-color: transparent;
outline-offset: 0;
}
}
@keyframes eb {
0% {
outline-width: 2px;
outline-color: transparent;
outline-offset: 0;
}
60% {
outline-width: 5px;
outline-color: rgba(55, 25, 255, 0.4);
outline-offset: 20px;
}
80% {
outline-width: 5px;
outline-color: #fff;
outline-offset: 40px;
}
100% {
outline-width: 2px;
outline-color: rgba(25, 155, 215 0.3);
outline-offset: 50px;
}
}
<link href="https://fonts.cdnfonts.com/css/railroadroman" rel="stylesheet">
<main>
<button class="A yang">
I <i>💓</i>
</button>
<button class="A ying">
II <i>💗</i>
</button>
<button class="B yang">
III <i>🖤</i>
</button>
<button class="B ying">
IV <i>💙</i>
</button>
</main>