About this snippet

Improve the perceived speed of your site with this image loading technique. Images start blurred and transition smoothly to sharp focus once loaded, which creates a polished and professional user experience.

Size
777 bytes
Uses
HTML, CSS
Loads
placehold.co
Views
466
<div class="blur-load" style="background-image: url('https://placehold.co/600x400/e2e8f0/ffffff?text=Loading')">
  <img src="https://placehold.co/600x400/3b82f6/ffffff?text=High+Res+Image" loading="lazy" onload="this.classList.add('loaded')">
</div>
.blur-load {
  font-family: system-ui, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
  width: 100%;
  max-width: 600px;
  aspect-ratio: 16 / 9;
  background-size: cover;
  background-position: center;
  position: relative;
  overflow: hidden;
  border-radius: 12px;
}
img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 0.5s ease-in-out;
  /* Initially hidden to show background placeholder */
}
img.loaded {
  opacity: 1;
}
Esc
↑↓ moveEnter select

Start from a template

Open an .html file, or HTML, CSS, JS, Markdown, Less or TypeScript files. You can also drop them here. Styles and scripts go into their panes.

Share

Source

Keyboard shortcuts

Save