<div class="card">
<div class="stuff">
<figure>
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg width="128" height="144" viewBox="0 0 128 144" version="1.1" xmlns="http://www.w3.org/2000/svg">
<path d="M0,142L8,142L8,144L0,144L0,142ZM28,142L32,142L32,144L28,144L28,142ZM96,142L104,142L104,144L96,144L96,142ZM80,100L76,100L76,114L72,114L72,120L68,120L68,124L64,124L64,140L68,140L68,144L60,144L60,132L56,132L56,128L52,128L52,132L48,132L48,136L44,136L44,140L48,140L48,144L40,144L40,128L36,128L36,124L32,124L32,120L28,120L28,116L24,116L24,112L20,112L20,88L24,88L24,96L28,96L28,100L32,100L32,104L40,104L40,100L44,100L44,96L50,96L50,92L56,92L56,88L60,88L60,62L64,62L64,58L96,58L96,62L100,62L100,80L80,80L80,84L92,84L92,88L76,88L76,96L84,96L84,104L80,104L80,100ZM82,140L84,140L84,142L82,142L82,140ZM12,136L20,136L20,138L12,138L12,136ZM110,134L116,134L116,136L110,136L110,134ZM0,128L32,128L32,130L0,130L0,128ZM72,128L128,128L128,130L72,130L72,128ZM68,64L68,68L72,68L72,64L68,64Z" stroke="none" fill="white"/>
</svg>
</figure>
</div>
<button class="delete-btn">
<img src="https://upload.wikimedia.org/wikipedia/commons/7/7d/Trash_font_awesome.svg" alt="close button">
<span class="sr-only">Delete</span>
</button>
</div>
/* Applied classes */
.fade-out {
animation: fade-out 0.25s forwards;
}
.spin-out {
animation: spin-and-delete 1s ease-in forwards;
}
/* Keyframe animations */
@keyframes fade-out {
100% {
opacity: 0;
display: none;
}
}
/* Rest of the demo */
@keyframes spin-and-delete {
0% {
transform: rotateY(0);
filter: hue-rotate(0);
}
80% {
transform: rotateY(360deg);
filter: hue-rotate(180deg);
opacity: 1;
}
100% {
opacity: 0;
display: none;
}
}
@layer base {
body {
display: grid;
height: 90dvh;
place-items: center;
}
.card {
width: 100%;
aspect-ratio: 2/3;
display: block;
background: linear-gradient(135deg, cyan, blue);
position: relative;
border-radius: 0 0 1rem 1rem;
max-width: 220px;
border: 0.5rem solid blue;
&:before {
content: '';
height: 1.5rem;
width: 100%;
display: block;
border: 0.5rem solid blue;
border-radius: 1rem 1rem 0 0;
position: absolute;
top: -2.5rem;
left: -0.5rem;
}
&:after {
content: '';
display: block;
position: absolute;
background: #00d56e;
height: 0.9rem;
width: 0.9rem;
top: -1.7rem;
border-radius: 1rem;
left: 0.35rem;
box-shadow: 1.25rem 0 0 #33c4ff, 2.5rem 0 0 #9673ff;
}
}
.delete-btn {
position: absolute;
bottom: -1.5rem;
right: 0;
left: 0;
margin: 0 auto;
width: 3.5rem;
height: 3.5rem;
padding: 0.5rem;
border: 0.25rem solid blue;
border-radius: 100%;
background: white;
&:hover,
&:focus {
background: lightgray;
}
}
.sr-only {
border: 0;
clip: rect(1px, 1px, 1px, 1px);
clip-path: inset(50%);
height: 1px;
margin: -1px;
overflow: hidden;
padding: 0;
position: absolute;
width: 1px;
white-space: nowrap;
}
svg {
width: 100%;
height: 100%;
}
figure {
margin: 0;
}
}
document.querySelector('.delete-btn').addEventListener('click', () => {
document.querySelector('.delete-btn').classList.add('fade-out'); document.querySelector('.card').classList.add('spin-out');
})
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.