Skip to content

Instantly share code, notes, and snippets.

@donwilson
Created August 23, 2018 17:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save donwilson/4a50e2211c079ca77ad861dece9a04fe to your computer and use it in GitHub Desktop.
Save donwilson/4a50e2211c079ca77ad861dece9a04fe to your computer and use it in GitHub Desktop.
Image container with blurry background CSS effect
<!doctype html>
<html>
<head>
<title>Blurred Background Image</title>
<style type="text/css">
body {
overflow: hidden;
}
.blur_background_container {
width: 120%;
height: 120%;
position: absolute;
top: -10%;
left: -10%;
overflow: hidden;
opacity: 1;
}
.blur_background_image {
width: 100%;
height: 100%;
background-size: cover;
background-position: 50%;
background-repeat: no-repeat;
filter: blur(30px);
-webkit-filter: blur(30px);
-moz-filter: blur(30px);
-o-filter: blur(30px);
-ms-filter: blur(30px);
}
.blur_background_content {
position: absolute;
top: 50%;
left: 50%;
margin-top: 0;
margin-left: 0;
display: inline-block;
}
.blur_background_content img {
display: block;
}
</style>
</head>
<body>
<div class="blur_background_container">
<div class="blur_background_image" style="background-image: url('https://i.imgur.com/i42YW86.jpg');"></div>
<div class="blur_background_content" style="margin-top: -165px; margin-left: -134px;"><!-- margins half image dimension -->
<img src="https://i.imgur.com/i42YW86.jpg" />
</div>
</div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment