Beating heart
Beating heart animation using CSS transforms & keyframe-animation
by Aditya
HTML
<!doctype html>
<html>
<head>
<title>Potato Potato Potato Potato</title>
</head>
<body>
<ul>
<li/>
<li/>
</ul>
</body>
</html>
CSS
:root {
--size: 40px;
--vsize: calc(var(--size) * 3);
--hsize: calc(var(--size) * 2);
}
html, body {
height: 99vh;
margin: 0;
padding: 0;
overflow: none;
}
body {
display: flex;
align-items: center;
justify-content: center;
background-color: #a0d6b4;
}
@keyframes scale {
30% { transform: scale(1); }
40% { transform: scale(1.1); }
50% { transform: scale(1); }
60% { transform: scale(1.1); }
70% { transform: scale(1); }
}
ul {
list-style: none;
margin: 0;
padding: 0;
animation-name: scale;
animation-duration: 1.5s;
animation-iteration-count: infinite;
}
li {
border-width: var(--vsize) var(--hsize);
border-radius: var(--hsize) var(--hsize) 0 0;
display: inline-block;
border-style: solid;
border-color: #ffffff;
}
li:first-child {
transform: translate(var(--size)) rotate(-45deg);
}
li:last-child {
transform: translate(var(--size)) rotate(45deg) translate(-45%, 30%);
}