<main>
<section>
<div class="content">
<h1>Blurred background with SVG filters</h1>
</div>
</section>
<section>
<div class="content">
<ul>
<li>
I used SVG filters for browser support.
</li>
<li>
The effect is comprised of the same fixed image layered on top of itself. The top layer is blurred and darkened.
</li>
<li>
Because filters affect the content of the element, I used absolutely positioned pseudo elements underneath the content.
</li>
</ul>
</div>
</section>
<section>
<div class="content">
<p>
Here are some things to allow scrolling.
</p>
<img src="http://placehold.it/400x100/eeeeee/666666&text=This+image+is+not+blurred">
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus sollicitudin dolor et orci mollis consectetur. Vestibulum neque massa, iaculis eget laoreet at, rutrum et nunc. Etiam faucibus, libero ut feugiat laoreet, velit nunc varius sapien, vitae commodo mi sapien sit amet mauris. Nullam at congue arcu. Mauris faucibus vitae ligula eu fringilla. Proin eget pulvinar eros, non aliquam lectus. Donec ornare, augue eget pellentesque posuere, nulla est imperdiet ipsum, id ullamcorper lacus ipsum nec nulla. Vestibulum ut imperdiet elit, at accumsan elit.
</p>
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus sollicitudin dolor et orci mollis consectetur. Vestibulum neque massa, iaculis eget laoreet at, rutrum et nunc. Etiam faucibus, libero ut feugiat laoreet, velit nunc varius sapien, vitae commodo mi sapien sit amet mauris. Nullam at congue arcu. Mauris faucibus vitae ligula eu fringilla. Proin eget pulvinar eros, non aliquam lectus. Donec ornare, augue eget pellentesque posuere, nulla est imperdiet ipsum, id ullamcorper lacus ipsum nec nulla. Vestibulum ut imperdiet elit, at accumsan elit.
</p>
<p>
An original pen by <a href="https://codepen.io/ejsado/">Eric</a>.
</p>
</div>
</section>
</main>
<svg version="1.1" xmlns="http://www.w3.org/2000/svg">
<filter id="svgfilter">
<feGaussianBlur stdDeviation="8" />
<!-- comment out feComponentTransfer to remove the darkness -->
<feComponentTransfer>
<feFuncR type="linear" slope="0.9"/>
<feFuncG type="linear" slope="0.9"/>
<feFuncB type="linear" slope="0.9"/>
</feComponentTransfer>
</filter>
</svg>
@import url(https://fonts.googleapis.com/css?family=Oswald:300,400,700);
$svgfilter: url("#svgfilter");
main {
width: 600px;
margin: 0 auto;
}
section {
margin: 70px 0;
position: relative;
-moz-border-radius: 20px;
-webkit-border-radius: 20px;
border-radius: 20px; /* future proofing */
-khtml-border-radius: 20px; /* for old Konqueror browsers */
overflow: hidden;
/* remove the overflow: hidden to have tapered edges */
}
.content {
padding: 30px;
}
h1, li, p {
color: #FFF;
font-family:'Oswald', 'Arial';
}
h1 {
text-align: center;
font-weight: 700;
letter-spacing: 5px;
text-transform: uppercase;
}
ul {
list-style-type: none;
margin: 0;
padding: 0;
}
li {
font-weight: 400;
padding: 10px 0;
font-size: 24px;
letter-spacing: 1px;
}
p {
font-weight: 300;
font-size: 18px;
letter-spacing: 1px;
}
a {
color: #A3CDF7;
}
body, section::before {
background: url(https://s3-us-west-2.amazonaws.com/s.cdpn.io/106891/san-francisco-street.JPG) no-repeat #000;
background-position: center;
background-size: cover;
background-attachment: fixed;
}
section::before {
content: "";
display: block;
z-index: -1;
-webkit-filter: $svgfilter;
-moz-filter: $svgfilter;
-o-filter: $svgfilter;
-ms-filter: $svgfilter;
filter: $svgfilter;
position: absolute;
width: 100%;
height: 100%;
margin: 0;
padding: 0;
}
svg {
width: 0;
height: 0;
margin: 0;
padding: 0;
border: 0;
}
View Compiled
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.