5

Is there a way to blur the background of a container, but not the text inside?

screenshot

  1. You have your fullscreen image first [already done by me ;-) Actually I'm using a pure css solution:

    background-size: cover;
    
  2. Than blurring the background of the (1000px) centered container (margin: 0 auto), but not the content in the container.

  3. The same container (margin: 0 auto; width: 1000px; ) (of course without the blur), where you can add html stuff (...text).

I'm hoping anyone can help me.

Glorfindel
  • 21,988
  • 13
  • 81
  • 109
Maximilian Fuchs
  • 441
  • 1
  • 6
  • 15

1 Answers1

3

Reduce the size of the actual image and in your HTML code put large dimensions for the width and height.

For example, have the width and height of the real image at perhaps 50px each. In the HTML code set the width and height to lets say, something like : 150px.

Now this will cause the image to get stretched and hence will give it a blurred effect.

Well, that was a logical approach.

If you want to use CSS (CSS3) do this:

filter: blur(5px) brightness(0.5);

just set the values to whatever you want..

Refrence: http://www.inserthtml.com/2012/06/css-filters/

hope that helps...

EDIT 1:

<div class="container">
    <div class="background"></div>
    <div class="text"></div>
</div>

put all your text in the div whose class is "text" and leave the div with class "background" empty..

also apply the following styles:

.background  {
    background: #CCC;
    filter: blur(5px) brightness(0.5);
    position: absolute;
    top: 0; left: 0;
    height: 100%; width:100%;
}
.text {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
}
Anshu Dwibhashi
  • 4,617
  • 3
  • 28
  • 59