<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/background-image-refraction-in-css-master-dev-blog-akrpxt5sa" -->

---
title: Background Image Refraction in CSS – Master.dev Blog
description: A technique for creating a realistic liquid-glass refraction effect using pure CSS is demonstrated, using the CSS view() function to track an element's...
canonical: https://daily.dev/posts/background-image-refraction-in-css-master-dev-blog-akrpxt5sa
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Background Image Refraction in CSS – Master.dev Blog | daily.dev
og:description: A technique for creating a realistic liquid-glass refraction effect using pure CSS is demonstrated, using the CSS view() function to track an element's...
og:url: https://daily.dev/posts/background-image-refraction-in-css-master-dev-blog-akrpxt5sa
og:image: https://api.daily.dev/og/posts/aKrPxT5SA.png
og:image:alt: Background Image Refraction in CSS – Master.dev Blog
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Background Image Refraction in CSS – Master.dev Blog

**[Frontend Masters](https://daily.dev/sources/frontendmasters)** · 5 min read · 6 upvotes · 1 comments

## Summary

A technique for creating a realistic liquid-glass refraction effect using pure CSS is demonstrated, using the CSS view() function to track an element's position within a scroll container instead of relying on fixed backgrounds tied to the viewport. By turning a container into a scroll container and applying view timelines on both x and y axes to animate a child element's background-position, the child's background automatically aligns with the corresponding part of the container's background image, even without actual scrolling. Resizing or shifting the child's background further introduces the refraction distortion, which can be layered with blur, shadow, and skew for a fuller glassmorphism look.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://blog.master.dev/background-image-refraction-in-css>

## Questions this post answers

### How can I create a liquid glass refraction effect using only CSS?

Turn the backdrop container into a scroll container with overflow hidden, give it a fixed background image, and make the child card inherit that background. Then animate the card's background-position using two linear keyframe animations tied to animation-timeline: view(x) and view(y) with animation-range: contain, so the card's background position tracks its visibility within the container automatically.

_daily.dev surfaces CSS techniques like this for developers building modern glassmorphism interfaces._

### Why shouldn't I use background-attachment: fixed for a refraction or glassmorphism effect?

Because the background image is positioned relative to the viewport rather than the backdrop element, requiring manual calculation of the backdrop's dimensions and screen position to align it correctly, which becomes difficult in responsive layouts. Using a scroll container with CSS view() timelines instead lets elements align their backgrounds automatically without tracking positions manually.

_developers debugging fixed-background layout quirks can follow CSS technique breakdowns like this on daily.dev._

### What does the CSS view() function do in animation-timeline?

It tracks an element's visibility position inside its nearest scroll container, producing a view progress timeline that can drive animations along the x-axis or y-axis separately. Because it only handles one axis at a time, two separate animations with animation-timeline: view(x) and view(y) are needed for two-dimensional tracking, such as syncing a background position to scroll visibility.

_daily.dev helps developers keep up with scroll-driven CSS animation features as they land in browsers._

## Community discussion

Top comments from developers on daily.dev.

**@nosfair** · 0 upvotes

> CSS is slowly making half of our old scroll event listeners look like technical debt. Love it.

## Similar posts on daily.dev

- [Liquid Glass in the Browser – Frontend Masters Blog](https://daily.dev/posts/liquid-glass-in-the-browser-frontend-masters-blog-aeuunx3ok) · Frontend Masters · 2 upvotes · 0 comments
- [What’s \!important \#19: CSS Refraction Effects, Scroll State Queries, @custom-media, and More](https://daily.dev/posts/what-s-important-19-css-refraction-effects-scroll-state-queries-custom-media-and-more-eadl0z3ki) · CSS-Tricks · 9 upvotes · 2 comments
- [How to create Liquid Glass effects with CSS and SVG](https://daily.dev/posts/how-to-create-liquid-glass-effects-with-css-and-svg-snrfnzbhd) · LogRocket · 4 upvotes · 0 comments
- [CSS Optical Illusions](https://daily.dev/posts/css-optical-illusions-w8odlyck4) · Hacker News · 5 upvotes · 1 comments

---

Tags: [#webdev](https://daily.dev/tags/webdev), [#css](https://daily.dev/tags/css)

[View this post on daily.dev](https://daily.dev/posts/background-image-refraction-in-css-master-dev-blog-akrpxt5sa)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Background Image Refraction in CSS – Master.dev Blog","url":"https://daily.dev/posts/background-image-refraction-in-css-master-dev-blog-akrpxt5sa","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/background-image-refraction-in-css-master-dev-blog-akrpxt5sa"},"datePublished":"2026-08-28T13:27:07.638Z","dateModified":"2026-09-14T06:08:13.024Z","description":"A technique for creating a realistic liquid-glass refraction effect using pure CSS is demonstrated, using the CSS view() function to track an element's...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/767bb451c928013c3eebf0e8fc907661?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/767bb451c928013c3eebf0e8fc907661?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"Frontend Masters","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Frontend Masters","logo":"https://media.daily.dev/image/upload/t_logo,f_auto/v1/logos/d34dd87208f24090bfb0917307fcf89f","url":"https://daily.dev/sources/frontendmasters"},"commentCount":1,"discussionUrl":"https://daily.dev/posts/background-image-refraction-in-css-master-dev-blog-akrpxt5sa","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":6},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":1}],"keywords":"webdev,css","timeRequired":"PT5M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Frontend Masters","item":"https://daily.dev/sources/frontendmasters"},{"@type":"ListItem","position":3,"name":"Background Image Refraction in CSS – Master.dev Blog"}]}
{"@context":"https://schema.org","@type":"WebPage","@id":"https://daily.dev/posts/background-image-refraction-in-css-master-dev-blog-akrpxt5sa","comment":[{"@type":"Comment","text":"CSS is slowly making half of our old scroll event listeners look like technical debt. Love it.","datePublished":"2026-09-10T06:59:51.985Z","url":"https://daily.dev/posts/aKrPxT5SA#c-QWOmrjYUl","author":{"@type":"Person","name":"Thialon","url":"https://daily.dev/nosfair","image":"https://avatars.githubusercontent.com/u/70216808?v=4"}}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/background-image-refraction-in-css-master-dev-blog-akrpxt5sa#faq","mainEntity":[{"@type":"Question","name":"How can I create a liquid glass refraction effect using only CSS?","acceptedAnswer":{"@type":"Answer","text":"Turn the backdrop container into a scroll container with overflow hidden, give it a fixed background image, and make the child card inherit that background. Then animate the card's background-position using two linear keyframe animations tied to animation-timeline: view(x) and view(y) with animation-range: contain, so the card's background position tracks its visibility within the container automatically. daily.dev surfaces CSS techniques like this for developers building modern glassmorphism interfaces."}},{"@type":"Question","name":"Why shouldn't I use background-attachment: fixed for a refraction or glassmorphism effect?","acceptedAnswer":{"@type":"Answer","text":"Because the background image is positioned relative to the viewport rather than the backdrop element, requiring manual calculation of the backdrop's dimensions and screen position to align it correctly, which becomes difficult in responsive layouts. Using a scroll container with CSS view() timelines instead lets elements align their backgrounds automatically without tracking positions manually. developers debugging fixed-background layout quirks can follow CSS technique breakdowns like this on daily.dev."}},{"@type":"Question","name":"What does the CSS view() function do in animation-timeline?","acceptedAnswer":{"@type":"Answer","text":"It tracks an element's visibility position inside its nearest scroll container, producing a view progress timeline that can drive animations along the x-axis or y-axis separately. Because it only handles one axis at a time, two separate animations with animation-timeline: view(x) and view(y) are needed for two-dimensional tracking, such as syncing a background position to scroll visibility. daily.dev helps developers keep up with scroll-driven CSS animation features as they land in browsers."}}]}
```

