Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <div class="container">
  <section class="card">
    <figure class="card-image skeleton"></figure>
    <div class="card-detail">
      <h3 class="card-title skeleton"></h3>
      <p class="card-description skeleton"></p>
    </div>
  </section>
</div>


              
            
!

CSS

              
                $border-color: #dae1e7;
$background-color: #f4f4f4;
$text-color: #333;

body {
  background: #f4f4f4;
  margin: 100px 0;
  padding: 0;
  font-family: system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen,Ubuntu,Cantarell,Fira Sans,Droid Sans,Helvetica Neue;
  color: $text-color;
}

.container {
  margin: 2rem auto;
  max-width: 800px;
  display: flex;
  justify-content: center;
}

.card {
  // overflow: hidden;
  background: white;
  border-radius: .25rem;
  max-width: 380px;
  width: 380px;
  box-shadow: 
    0 15px 30px 0 rgba(0,0,0,0.05),
    0 5px 15px 0 rgba(0,0,0,.05);
  transition: ease box-shadow 0.3s;
  &:hover {
   box-shadow: 
    0 15px 60px 0 rgba(0,0,0,0.08),
    0 5px 25px 0 rgba(0,0,0,.08);
  }
}

.card-detail {
  padding: .5rem 1rem;
  
  h3 { 
    font-size: 1.5rem; 
    margin-bottom: none; 
    line-height: .09;
  }
  
  p {
    line-height: 1.3rem;  
  }
}

.card-image {
  margin: 0;
  padding: 0;
  height: 200px;
  overflow: hidden;
  
  img {
    max-width: 100%;
    height: auto;
  }
}


.skeleton {
  position: relative;
  background-color: #E2E2E2;
  overflow: hidden;
  
  &.card-image {
    border-radius: 0;
  }
  
  &::after {
    display: block;
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    transform: translateX(-100%);
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .2), transparent);
    animation: loading 1.5s infinite;
  }
}

@keyframes loading {
  100% {
    transform: translateX(100%);
  }
}

.card-title.skeleton {
  height: 1.8rem;
}

.card-image.image {
  max-width: 100%;
  height: auto;
}

.card-description.skeleton {
  height: 80px;
}
              
            
!

JS

              
                /* Let's Build: With JavaScript - Web-Crunch.com
   Subscribe on YouTube - https://youtube.com/c/webcrunch
   
   Let's Build: Skeleton Screens 
*/

const cardImage = document.querySelector('.card-image');
const cardTitle = document.querySelector('.card-title');
const cardDesc = document.querySelector('.card-description');


const renderCard = () => {
  cardTitle.textContent = 'Card Title Yo!';  
  cardDesc.textContent = 'Lorem ipsum dolor, sit amet consectetur adipisicing elit. Vero dicta repellat quibusdam assumenda at distinctio similique eos? Officiis voluptatem accusamus, id odit, quos eaque nemo, dicta quidem eum eligendi veritatis.';
  createImage();
  cardTitle.classList.remove('skeleton');
  cardDesc.classList.remove('skeleton');
  cardImage.classList.remove('skeleton');
};

function createImage() {
  const img = new Image();
  img.classList.add("image");
  img.setAttribute('alt', 'A cloud day at a mountain base');
  img.setAttribute('src', 'https://images.unsplash.com/photo-1516646255117-f9f933680173?ixlib=rb-0.3.5&q=85&fm=jpg&crop=entropy&cs=srgb&ixid=eyJhcHBfaWQiOjE0NTg5fQ&s=dc874984018a4253ba7d2a3c53387135');
  cardImage.appendChild(img);
}

setTimeout(() => {
  renderCard();
}, 5000000);

// window.addEventListener('load', () => {
//   renderCard();
// });
              
            
!
999px

Console