5

Let's say my site is arranged like this in terms of layers.

  • Background Image ( background-size:cover;)
  • 500 x 500 div with a semi-transparent white background.
  • Content within the div.

What I'd like is that the area under the div (on the background image) to be be blurred. My problem is that with varying screen sizes, I can't have the background image "pre-blurred" because that div will not always be aligned with the background.

So my question is, is it possible to blur a specific portion of a background image on the fly by maybe defining the region like I would for the div? For example position:absolute; top:45% right:0; Or what's my best cross-browser options. CSS or other wise, it doesn't matter.

Thanks


On a side note I've thought about having a div inbetween the background and the previously talked about div with a background image the same as the one behind it but set it's background position to match the foreground div and just blur it. Kinda like zooming into a photo in programs like ps and the box in the navigator refers to only that part of the image being showed.

user229044
  • 232,980
  • 40
  • 330
  • 338

2 Answers2

1

This may be a little heavy for what you're trying to do, but you could use Blur.js

$('.target').blurjs({ 
    source: 'body',
    radius: 10, 
});

Should you need to blur more than just the background, checkout:
https://stackoverflow.com/a/17134789/1947286

Community
  • 1
  • 1
apaul
  • 16,092
  • 8
  • 47
  • 82
0

You can overlay one picture with another (using divs) and blur the overlay.

<div style="position: relative; background: URL(...)">

<div style="position: absolute; background: URL(...); 
       top: ...; left: ...; width: ...; height: ...; filter: blur(3px)">

Update: Here it is in perfection: http://css-tricks.com/blurry-background-effect/

Ondra Žižka
  • 43,948
  • 41
  • 217
  • 277
  • Here's my issue though. That may work for #menu but not #logo because as the browser resizes the blur won't match the image. – Martin Powlette Jr Jul 06 '13 at 02:24
  • Hmm... how about having another image, blurred, and pushing it's position up for the menu and logo? That would, by the way, cost less CPU on client's side... but more bandwidth. – Ondra Žižka Jul 06 '13 at 02:34
  • Also, how about a small cheat - a semi-transparent light-grey background. I know, not really the same. – Ondra Žižka Jul 06 '13 at 02:36
  • I've thought about that but my thing is I want the background to change and make sure it's always perfect interms of alignment. – Martin Powlette Jr Jul 06 '13 at 02:43