How to create a blurry background image with CSS?

CSSWeb DevelopmentFront End Technology

Following is the code to create a blurry background image with CSS −

Example

 Live Demo

<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<style>
body,
html {
   height: 100vh;
   margin: 0;
   font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
}
* {
   box-sizing: border-box;
}
.backgroundImage {
   background-image: url("https://images.pexels.com/photos/1172207/pexels-photo-1172207.jpeg?auto=compress&cs=tinysrgb&dpr=1&w=500");
   filter: blur(10px);
   height: 100%;
   background-position: center;
   background-repeat: no-repeat;
   background-size: cover;
}
.transparentText {
   background-color: rgba(0, 0, 0, 0.4);
   color: white;
   border: 3px solid #f1f1f1;
   position: absolute;
   top: 40%;
   left: 30%;
   width: 50%;
   padding: 20px;
   text-align: center;
}
</style>
</head>
<body>
<div class="backgroundImage"></div>
<div class="transparentText">
<h1>I am Shawn</h1>
<h1>I am a web developer</h1>
</div>
</body>
</html>

Output

The above code will produce the following output −

raja
Published on 06-Apr-2020 16:42:13
Advertisements