by timdorr on 12/3/24, 3:43 AM with 65 comments
by andai on 12/7/24, 12:53 AM
It makes me very happy that someone not only noticed this, but did something about it, and then shared it freely!
by chrismorgan on 12/7/24, 4:19 AM
First question: how much more do you need? Per https://drafts.fxtf.org/filter-effects/#funcdef-filter-blur (via MDN blur() docs → link to spec):
> Note: A true Gaussian blur has theoretically infinite extent, but in practice all implementations use a finite-area approximation of a Gaussian blur. At the time of writing (January 2024) all major implementations use the familiar three-pass box blur approximation, which has extent: ((3 * sqrt(2 * π) / 4) * σ).
¾√2π is about 1.88; it’s generally most convenient to just double the radius instead.
So, if you’re going for a 16px blur, add 32px. (The formula would make it 30.079px; so I’d accept 30px and 31px also.)
In the first main demo with code: ditch the `height: 200%`, change the inset to `0 0 -32px 0`, and change the 50% in the mask-image linear-gradient to calc(100% - 32px). (Aside: you can also shorten the gradient definition: linear-gradient(to bottom, black calc(100% - 32px), transparent 0%).) Applying it to later things is left as an exercise to the reader.
The SVG <filter> element is interesting in this rendering size question: it lets you control the rendering area for the filter, via its x, y, width and height attributes. Their defaults are -10%, -10%, 120% and 120%, meaning 10% overdraw on each edge. Unfortunately you can’t really do height="calc(100% + 32px)" which is what you’d want for the equivalent here. Yes, you could definitely do this whole thing in SVG, using the BackgroundImage source—in fact, you can do better, because you can composite that with SourceAlpha, rather than the dodgy mask-image technique you’re limited to in HTML/CSS. Unfortunately I don’t believe any current browsers support BackgroundImage, though I think IE and Opera used to, and Inkscape does.
by KaoruAoiShiho on 12/7/24, 2:02 AM
by spiffyk on 12/7/24, 3:17 PM
by webstrand on 12/7/24, 1:34 AM
by sureIy on 12/7/24, 9:13 AM
It's great to experiment, but don't use this in projects that you intend to maintain.
Signed, someone who used to do this a lot.
by bldng on 12/7/24, 7:17 PM
Chrome & Safari render it differently but interesting, Firefox is skipping it completely … I‘d need to look into it. Anyway, just wanted to share it :)
by IAmGraydon on 12/7/24, 3:11 AM
by seltzered_ on 12/7/24, 4:10 AM
by fracus on 12/7/24, 7:08 PM
by Etheryte on 12/7/24, 6:20 PM
by strongpigeon on 12/7/24, 1:10 AM
by vintagedave on 12/7/24, 2:52 PM
Firefox on Mac _may_ have a slight lag scrolling now which Chrome does not show.
Not mentioned in the article (that I saw) is that despite being a background blur it will affect all elements placed in the header, even with z-index higher than the blur, unless you mark them `position: relative;`. I added that style to my nav container.
by refulgentis on 12/7/24, 6:35 AM
by madeofpalk on 12/7/24, 6:54 PM
Also ran into odd colour issues in Firefox when combining it also with opacity.
by jp1016 on 12/7/24, 5:35 PM
by zipy124 on 12/7/24, 5:08 PM
by eps on 12/7/24, 9:29 AM
A bit too "next-level" for my iPad it seems.
by ndesaulniers on 12/7/24, 12:58 AM
by hanifbbz on 12/7/24, 6:51 AM
by lbotos on 12/7/24, 12:43 PM
by kamens on 12/7/24, 9:04 AM
by tbolt on 12/7/24, 1:19 AM