How TO – Blurred Background Image


Previous


Next

Learn how to create a blurry background image with CSS.

Example

<!DOCTYPE html>
<html>
<head>
<meta name=”viewport” content=”width=device-width, initial-scale=1″>
<style>
body, html {
height: 100%;
margin: 0;
font-family: Arial, Helvetica, sans-serif;
}

* {
box-sizing: border-box;
}

.bg-image {
/* The image used */
background-image: url(“photographer.jpg”);

/* Add the blur effect */
filter: blur(8px);
-webkit-filter: blur(8px);

/* Full height */
height: 100%;

/* Center and scale the image nicely */
background-position: center;
background-repeat: no-repeat;
background-size: cover;
}

/* Position text in the middle of the page/image */
.bg-text {
background-color: rgb(0,0,0); /* Fallback color */
background-color: rgba(0,0,0, 0.4); /* Black w/opacity/see-through */
color: white;
font-weight: bold;
border: 3px solid #f1f1f1;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
z-index: 2;
width: 80%;
padding: 20px;
text-align: center;
}
</style>
</head>
<body>

<div></div>

<div>
<h2>Blurred Background</h2>
<h1 style=”font-size:50px”>I am John Doe</h1>
<p>And I’m a Photographer</p>
</div>

</body>
</html>

How To Create a Blurry Background Image

Step 1) Add HTML:

Example

<div class=”bg-image”></div>

<div class=”bg-text”>
  <h1>I am John Doe</h1>
  <p>And I’m a Photographer</p>
</div>

Step 2) Add CSS:

Example

<!DOCTYPE html>
<html>
<head>
<meta name=”viewport” content=”width=device-width, initial-scale=1″>
<style>
body, html {
height: 100%;
margin: 0;
font-family: Arial, Helvetica, sans-serif;
}

* {
box-sizing: border-box;
}

.bg-image {
/* The image used */
background-image: url(“photographer.jpg”);

/* Add the blur effect */
filter: blur(8px);
-webkit-filter: blur(8px);

/* Full height */
height: 100%;

/* Center and scale the image nicely */
background-position: center;
background-repeat: no-repeat;
background-size: cover;
}

/* Position text in the middle of the page/image */
.bg-text {
background-color: rgb(0,0,0); /* Fallback color */
background-color: rgba(0,0,0, 0.4); /* Black w/opacity/see-through */
color: white;
font-weight: bold;
border: 3px solid #f1f1f1;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
z-index: 2;
width: 80%;
padding: 20px;
text-align: center;
}
</style>
</head>
<body>

<div></div>

<div>
<h2>Blurred Background</h2>
<h1 style=”font-size:50px”>I am John Doe</h1>
<p>And I’m a Photographer</p>
</div>

</body>
</html>


Previous


Next

Scroll to Top