
<div class="box skew-x">Skew X</div>
<div class="box skew-y">Skew Y</div>
<div class="box skew">Skew XY</div>
<style>
.box {
width: 100px;
height: 50px;
background-color: orange;
color: white;
text-align: center;
line-height: 50px;
margin: 10px;
transition: transform 0.3s ease-in-out;
}
.skew-x:hover {
transform: skewX(-20deg); /* 마우스 호버 시 X축으로 -20도 기울임 */
}
.skew-y:hover {
transform: skewY(15deg); /* 마우스 호버 시 Y축으로 15도 기울임 */
}
.skew:hover {
transform: skew(-30deg, -10deg); /* 마우스 호버 시 X축 -30도, Y축 -10도 기울임 */
}
</style>
scroll (기본값)
<div class="container bg-scroll">Scroll Background</div>
<div class="container bg-fixed">Fixed Background</div>
<div class="container bg-local">
<div class="content">Local Background Content<br>... (긴 내용) ...</div>
</div>
<style>
.container {
width: 300px;
height: 200px;
margin: 20px;
color: white;
text-align: center;
line-height: 200px;
border: 1px solid black;
}
.bg-scroll {
background-image: url('texture.png');
background-attachment: scroll; /* 스크롤될 때 함께 움직임 (기본값) */
}
.bg-fixed {
background-image: url('landscape.jpg');
background-attachment: fixed; /* 뷰포트에 고정되어 스크롤해도 움직이지 않음 */
background-size: cover; /* 배경 이미지를 요소 전체에 채움 */
}
.bg-local {
height: 150px;
overflow-y: scroll;
background-image: url('dots.png');
background-attachment: local; /* 요소 내부 스크롤 시 함께 움직임 */
}
.bg-local .content {
height: 400px; /* 내용 높이 400px (스크롤 발생) */
padding: 10px;
background-color: rgba(255, 255, 255, 0.8);
color: black;
line-height: 1.5;
}
</style>
<div class="masked image-mask"></div>
<div class="masked gradient-mask"></div>
<div class="masked text-mask">Text Mask</div>
<style>
.masked {
width: 200px;
height: 150px;
margin: 20px;
display: inline-block;
background-color: gold;
color: white;
font-size: 24px;
line-height: 150px;
text-align: center;
}
.image-mask {
-webkit-mask-image: url('star.svg'); /* 마스크 이미지 (크롬, 사파리) */
mask-image: url('star.svg'); /* 마스크 이미지 */
-webkit-mask-size: contain; /* 마스크 이미지 크기 조절 (비율 유지하며 요소 안에 맞춤) */
mask-size: contain; /* 마스크 이미지 크기 조절 (비율 유지하며 요소 안에 맞춤) */
-webkit-mask-repeat: no-repeat; /* 마스크 이미지 반복 없음 */
mask-repeat: no-repeat; /* 마스크 이미지 반복 없음 */
}
.gradient-mask {
-webkit-mask-image: linear-gradient(rgba(0, 0, 0, 1), rgba(0, 0, 0, 0));
/* 그라디언트 마스크 (크롬, 사파리) - 아래로 갈수록 투명해짐 */
mask-image: linear-gradient(rgba(0, 0, 0, 1), rgba(0, 0, 0, 0));
/* 그라디언트 마스크 - 아래로 갈수록 투명해짐 */
}
.text-mask {
background-image: url('pattern.png');
color: transparent; /* 글자색 투명하게 */
-webkit-background-clip: text; /* 배경을 텍스트 영역에만 적용 (크롬, 사파리) */
background-clip: text; /* 배경을 텍스트 영역에만 적용 */
}
</style>