A Pen by Cristi Nebunu on CodePen.
Created
April 2, 2024 17:34
-
-
Save ashrocket/1c0690b7577c9d09e203076a960e49ce to your computer and use it in GitHub Desktop.
Content Loading Placeholder
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<main class="page"> | |
<!-- Title --> | |
<h1 class="page-title">Content Loading Placeholder</h1> | |
<!-- Content --> | |
<div class="page-content"> | |
<!-- Placeholder Content --> | |
<div class="placeholder-content"> | |
<div class="placeholder-content_item"></div> | |
<div class="placeholder-content_item"></div> | |
<div class="placeholder-content_item"></div> | |
<div class="placeholder-content_item"></div> | |
<div class="placeholder-content_item"></div> | |
<div class="placeholder-content_item"></div> | |
<div class="placeholder-content_item"></div> | |
<div class="placeholder-content_item"></div> | |
<div class="placeholder-content_item"></div> | |
<div class="placeholder-content_item"></div> | |
<div class="placeholder-content_item"></div> | |
</div> | |
</div> | |
</main> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.page { | |
width: 650px; | |
margin: 10% auto 0; | |
padding: 20px; | |
background: #e5e5e5; | |
&-title { | |
margin-top: 5px; | |
margin-bottom: 10px; | |
} | |
&-content { | |
background: #fff; | |
padding: 25px 0; | |
} | |
} | |
.placeholder-content { | |
height: 205px; | |
overflow: hidden; | |
background: #000; | |
position: relative; | |
// Animation | |
animation-duration: 1.7s; | |
animation-fill-mode: forwards; | |
animation-iteration-count: infinite; | |
animation-timing-function: linear; | |
animation-name: placeholderAnimate; | |
background: #f6f7f8; // Fallback | |
background: linear-gradient(to right, #eee 2%, #ddd 18%, #eee 33%); | |
background-size: 1300px; // Animation Area | |
&_item { | |
width: 100%; | |
height: 20px; | |
position: absolute; | |
background: #fff; | |
z-index: 2; | |
&:after, | |
&:before { | |
width: inherit; | |
height: inherit; | |
content: ''; | |
position: absolute; | |
} | |
&:nth-child(1) { | |
top: 0; | |
left: 0; | |
} | |
&:nth-child(2) { | |
top: 20px; | |
left: 0; | |
width: 10%; | |
height: 90px; | |
} | |
&:nth-child(3) { | |
top: 0px; | |
left: 0; | |
width: 10%; | |
height: 100%; | |
} | |
&:nth-child(4) { | |
top: 20px; | |
width: 20px; | |
left: 170px; | |
height: 90px; | |
} | |
&:nth-child(5) { | |
top: 40px; | |
left: 190px; | |
height: 12px; | |
} | |
&:nth-child(6) { | |
top: 75px; | |
left: 190px; | |
height: 12px; | |
} | |
&:nth-child(7) { | |
top: 20px; | |
right: 0; | |
width: 23%; | |
height: 20px; | |
} | |
&:nth-child(8) { | |
top: 0; | |
right: 0; | |
width: 10%; | |
height: 100%; | |
} | |
&:nth-child(9) { | |
top: 110px; | |
height: 17px; | |
left: 0; | |
} | |
&:nth-child(10) { | |
top: 149px; | |
height: 12px; | |
left: 0; | |
} | |
&:nth-child(11) { | |
top: 183px; | |
left: 0; | |
height: 100%; | |
} | |
} | |
} | |
@keyframes placeholderAnimate { | |
0%{ background-position: -650px 0; } | |
100%{ background-position: 650px 0; } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment