여러분이 사용하고 계신 브라우저는 HTML5를 지원하지 않기 때문에 몇몇 요소가 제대로 보이도록 JScript를 사용하고 있습니다. 하지만 여러분의 브라우저 설정에서 스크립트 기능이 꺼져있으므로, 현재 페이지를 제대로 확인하시려면 스크립트 기능을 켜주셔야 합니다. How To - 흐린 배경 이미지
How To – 흐린 배경 이미지
7개월전 작성
7개월전 수정

w3.css

흐린 배경 이미지

CSS를 사용하여 흐린 배경 이미지를 만드는 방법을 알아보자.

⭐ 이 예는 Edge 12, IE 11 또는 이전 버전에서는 작동하지 않는다.

흐린 배경 이미지를 만드는 방법

1단계) HTML 추가
<div class="bg-image"></div>

<div class="bg-text">
  <h1>I am John Doe</h1>
  <p>And I'm a Photographer</p>
</div>
2단계) CSS 추가
body, html {
  height: 100%;
}

* {
  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;
}

기본 예시
예제 보기

참고

Mingg`s Diary
밍구
밍구
공부 목적 블로그