Home / 3D and Depth / Depth Blur

Depth Blur CSS Template, Free with Live Demo

Free depth blur template for a winery. Near and far layers blur while the middle stays sharp, like a camera lens, and focus shifts on scroll. Live demo. The example is Terraza, a family winery.

Open live demoDownload HTML fileView code on GitHub
Depth Blur CSS template example: Terraza, a family winery

What is depth blur?

Depth blur copies what a camera lens does: the thing in focus is sharp, and everything nearer or further away is soft. It pulls the eye straight to the message and makes a flat scene feel deep.

The scene has three layers with different blur amounts. As you scroll, the focus moves from the vines to the hills behind them, like a film pulling focus, using a few lines of JavaScript and CSS filter.

Good for

  • Wineries, farms and food brands
  • Photography and film sites
  • Hotels and travel
  • Any hero that needs a clear focal point

What you get in this template

The key CSS

This is the part that makes the depth blur look work. Copy it into your own project.

.far  { filter: blur(6px); }
.mid  { filter: blur(0); }
.near { filter: blur(10px); }
.card { background: rgba(246, 239, 228, .82); backdrop-filter: blur(10px); }

/* JS: shift focus on scroll */
far.style.filter = `blur(${6 - p * 6}px)`;
mid.style.filter = `blur(${p * 5}px)`;

How to use it

  1. Click Download HTML file above.
  2. Open the file in any code editor, like VS Code.
  3. Change the text, colors and links to match your project. Colors are at the top of the style tag.
  4. Upload it to any host, such as GitHub Pages, Netlify or your own server. It is one file with no build step.

Questions people ask

How do you create a depth of field effect in CSS?

Split the scene into layers and blur the near and far ones with filter: blur(), keeping the focus layer sharp.

Is filter: blur() slow?

It is fine on a few large layers. Avoid animating heavy blurs on many elements at once, especially on phones.

Can I use real photos?

Yes. Cut your photo into foreground and background layers as transparent PNGs and blur them separately.

More 3D and Depth designs