여러 배경 속성 결합하기
이 단계에서는 여러 배경 속성을 결합하여 더 복잡하고 흥미로운 배경 디자인을 만드는 방법을 배웁니다. ~/project 디렉토리에 있는 styles.html 파일을 수정하여 고급 배경 스타일링 기법을 시연해 보겠습니다.
styles.html 파일을 다음 내용으로 업데이트합니다.
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>Multiple Background Properties</title>
<style>
.image-container {
width: 600px;
height: 400px;
border: 2px solid black;
margin: 20px;
color: white;
font-weight: bold;
padding: 20px;
}
.multiple-backgrounds {
background-image:
linear-gradient(rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.5)),
url("background-sample.jpg");
background-size: cover, cover;
background-position: center, center;
background-repeat: no-repeat, no-repeat;
}
.layered-backgrounds {
background-image:
url("small-pattern.jpg"), linear-gradient(to right, #ff6b6b, #4ecdc4);
background-size:
100px 100px,
cover;
background-position:
top left,
center;
background-repeat: repeat, no-repeat;
}
</style>
</head>
<body>
<div class="image-container multiple-backgrounds">
Overlay Background with Image
</div>
<div class="image-container layered-backgrounds">
Layered Background with Pattern and Gradient
</div>
</body>
</html>
small-pattern.jpg는 ~/project 디렉토리에 있습니다.
이 예시는 두 가지 고급 배경 기법을 보여줍니다.
-
오버레이를 사용한 여러 배경:
- 선형 그라데이션을 사용하여 반투명 오버레이를 만듭니다.
- 그라데이션과 배경 이미지를 결합합니다.
- 일관된 크기, 위치 및 반복을 적용합니다.
-
계층화된 배경:
- 반복되는 패턴 이미지와 선형 그라데이션을 결합합니다.
- 각 배경 레이어에 대해 다른 크기와 위치를 사용합니다.
이 HTML 파일을 브라우저에서 열면 여러 배경 속성을 사용하여 복잡하고 시각적으로 흥미로운 디자인을 만들 수 있습니다.