다음은 CSS로 흐릿한 배경 이미지를 만드는 코드입니다 −
예시
<!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> 출력
위의 코드는 다음 출력을 생성합니다 -
