10

I want that the unregistered users on my website, see the entire website's pages with a blur effect.

How can I create this blur effect with css ?

xRobot
  • 25,579
  • 69
  • 184
  • 304
  • 3
    blur effect as in fuzzy, blurry? Or as in greyed out. You need to be more specific. – Jeremy B. Jun 07 '11 at 14:52
  • 2
    Which browsers/versions do you need to support? – thirtydot Jun 07 '11 at 14:56
  • 3
    In my opinion this is crazy - if you're hiding content with css then anyone with a little knowledge of how css works could "unblur" your page and see all your content. Why not display a static blurry screenshot of the content (or something similar) instead? – Ant Jun 07 '11 at 15:04
  • 3
    I disagree that it's a bad idea, it could just be adding a stylistic touch. I started searching for a similar effect - in my case I'm blurring content under an overlay. An by blur, I mean as in the "blur" added to a .jpg graphic when compressing - do you mean the same thing xRobot? – danjah Jul 18 '11 at 12:22
  • Even if css blur was possible, using it to protect your online content will be easily circumvented. But even the motivation for this question may or may not be correct, the actual question of "how do I create a blur effect in css?" is a very valid one. – aaaidan Feb 17 '12 at 01:37
  • I want to achieve the same effect, but it has nothing to do with content protection. Just with design. – MC Emperor Sep 05 '13 at 19:56
  • Possible duplicate of [Full Page Blur in CSS](http://stackoverflow.com/questions/371209/full-page-blur-in-css) – doppelgreener May 02 '17 at 16:25

5 Answers5

8

Try this...

body {
   filter:blur(3px);
}

You'll need to add -moz-, -webkit- prefixes (or use something like PrefixFree)

Patrick Clancey
  • 1,330
  • 1
  • 14
  • 22
5

Here's some results, if by blur you mean fuzziness:

This guy uses image shifting and opacity techniques in combo, I know your users are looking at a blurred website, but if there's no easy solution then perhaps taking a snapshot of your rego page and overlaying the image then it might do:

http://web.archive.org/web/20120211000759/http://simurai.com/post/716453142/css3-image-blur

If you wanted to attempt duplicating your rego page, given that it may be a) disabled and b) minimal, then perhaps you could even have a bash at using the above image technique and applying it to node sets, offsetting the copies with CSS positioning and opacity - idk if zoom might help you too there. Even if your page was minimal enough, this would obviously require Javascript to duplicate the nodes, unless your backend can do this node duplication. Just an idea, really. Here's a really awful, very quick example:

http://jsfiddle.net/9qnsz/2/

This SO posts outlines some of the limitations and difficulties with gaussian blur when not done with image, and has some interesting links:

Gaussian Blur onHover Using jQuery


EDIT: As requested, the contents of the jsfiddle:

<div class="container">
    <div class="overlay">
        <p>Please register etc etc...</p>
    </div>

    <form action="javascript:;" class="form0">
        <input type="text" value="Username" />
        <input type="text" value="Password" />
        <button>Submit</button>
    </form>
    <form action="javascript:;" class="form1">
        <input type="text" value="Username" />
        <input type="text" value="Password" />
        <button>Submit</button>
    </form>
    <form action="javascript:;" class="form2">
        <input type="text" value="Username" />
        <input type="text" value="Password" />
        <button>Submit</button>
    </form>
    <form action="javascript:;" class="form3">
        <input type="text" value="Username" />
        <input type="text" value="Password" />
        <button>Submit</button>
    </form>
    <form action="javascript:;" class="form4">
        <input type="text" value="Username" />
        <input type="text" value="Password" />
        <button>Submit</button>
    </form>

</div>​


.container {
    width:500px;
    height:500px;
    position:relative;
    border:1px solid #CCC;
}
    form {
        position:absolute;
        left:10px;
        top:10px;
    }
    form.form0 {
        left:11px;
        top:11px;
        opacity:0.1;
    }
    form.form1 {
        left:8px;
        top:8px;
        opacity:0.1;
        zoom:1.02;
    }
    form.form2 {
        left:11px;
        top:11px;
        opacity:0.1;
        zoom:1.01;
    }
    form.form3 {
        left:9px;
        top:9px;
        opacity:0.2;
    }
    form.form4 {
        left:11px;
        top:11px;
        opacity:0.1;
    }

    .overlay {
        width:250px;
        height:250px;
        margin-top:50px;
        margin-left:auto;
        margin-right:auto;
        border:1px solid #666;
    }
Community
  • 1
  • 1
danjah
  • 2,939
  • 2
  • 30
  • 47
  • The simurai.com link 404's now. – rossisdead Jul 05 '12 at 12:58
  • 1
    Gooooo link-rot! But meh, the text description above the link pretty much explains what happened on that now dead link. – danjah Jul 08 '12 at 22:38
  • 1
    @Danjah Please post the relevant answer from the fiddle into the answer; otherwise when that link dies or is moved, your answer becomes useless. – George Stocker Oct 03 '12 at 13:03
  • @GeorgeStocker There you go! Just curious - is everyone required to add their jsfiddle input into their answers, posts and comments now? – danjah Oct 08 '12 at 23:38
4

Edit (2015): The filter css property is forming tantalisingly complete coverage. This lets you write rules like body { filter: blur(10px); }, which blurs the entire page.


From what I can tell, there's no cross-browser way of blurring an element, even in this "modern age" of html5, css3, etc...

There is a blur filter for IE (and only IE). An svg blur filter can also be applied to an html element but from what I can tell, it only works in Firefox.

If you're happy for browser-specific hacks, go ahead, but if you need the effect to work on all browsers you're outta luck.

If you just want to blur text, you can use a clever text-shadow trick:

.blurry {
  color: transparent;
  text-shadow: 0 0 3px black; /* set to colour you want */
}

There are also ways to blur images, either by overlaying transparent, shifted copies of the image, or by processing the data with javascript.

Perhaps you can cobble together these techniques, and it will achieve what you want.

But the broad answer, regrettably, for the moment is: there is no easy, holistic way to blur stuff in HTML.

(I thought we were living in the future, man? What gives?!)

Addendum: Hope is in sight. At the time of writing, some webkit nightly ("bleeding edge") builds are implementing some of the new css filter specification. That demo doesn't work on any webkit browser I have installed, so it's still far from mainstream yet.

aaaidan
  • 7,093
  • 8
  • 66
  • 102
-1

You can add a fixed div set to 100% width and height to your body. That will fill the screen and you can put either a semi-transparent background on it or use CSS3 to create the effect you are looking for.

js1568
  • 7,012
  • 2
  • 27
  • 47
  • 1
    @aaaidan See this example: http://lab.simurai.com/iloveblur/ Basically set all text to have transparent color and a text-shadow. – js1568 Feb 27 '12 at 19:57
  • That's a cool demo! Indeed it is a nice effect, and definitely equivalent to a blur. Unfortunately you can only use that technique on text, not to images, borders, fills, etc. (Notice that the heart in that example is a unicode heart! Sneaky!) – aaaidan Feb 28 '12 at 03:33
  • The I Love Blur demo was moved. Here's the new URL: http://simurai.com/lab/2010/06/10/i-love-blur – Jargs Jun 18 '14 at 17:33
-2

Create a new div tag with id="body_bag" and put your rest of the site edits within that div and use following css to give the blur effect.

#body_bag {
    position: absolute;
    width: 100%;
    top: 0;
    left: 0;
    background: #000;
    opacity: 0.5;
    filter: alpha(opacity = 50); /* required for opacity to work in IE */
}
thirtydot
  • 224,678
  • 48
  • 389
  • 349
Kanchana Randika
  • 550
  • 2
  • 12
  • 27