Skip to content

Instantly share code, notes, and snippets.

@caeb92
Created October 25, 2020 15:46
Show Gist options
  • Save caeb92/09d7cee154d58cf2d35e74bb1da6c670 to your computer and use it in GitHub Desktop.
Save caeb92/09d7cee154d58cf2d35e74bb1da6c670 to your computer and use it in GitHub Desktop.
Medium - skeletons
/* BASE SKELETON*/
.skeleton {
display: inline-block;
height: 1em;
position: relative;
overflow: hidden;
background-color: #bdbdbd;
border-radius: 2px;
}
/*SHIMMER EFFECT*/
.skeleton::after {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
transform: translateX(-100%);
background-image: linear-gradient(
90deg,
rgba(255, 255, 255, 0) 0,
rgba(255, 255, 255, 0.2) 20%,
rgba(255, 255, 255, 0.5) 60%,
rgba(255, 255, 255, 0)
);
animation: shimmer 2s infinite;
content: "";
}
@keyframes shimmer {
100% {
transform: translateX(100%);
}
}
<div class="skeleton" style="height: 56px; width: 56px; border-radius: 50%; margin-right: 24px; margin-bottom: 24px;"></div>
<div class="skeleton" style="height: 32px; width: 80%; margin-bottom: 32px;"></div>
<div class="skeleton" style="height: 64px; width: 100%;"></div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment