• 회원가입
  • 로그인
  • 구글아이디로 로그인

[background] CSS - mix-blend-mode 속성 = 해당요소의 부모요소 배경색과의 '결합/혼합' 방법 지정 (= mix-blend-mode속성 = 믹스블렌드모드속성) ※ 종이 오려낸 텍스트 글자 효과

목차
  1. mix-blend-mode 예제 - screen 속성값 경우
  2. mix-blend-mode 정의
  3. mix-blend-mode 구문
  4. mix-blend-mode 예제 - 속성값별 효과 차이
  5. mix-blend-mode 예제 - 반응형 컷아웃(cutout) 텍스트 효과

 

mix-blend-mode 예제 - screen 속성값 경우

(예) screen 속성값 경우, 두 색을 반전시키고 곱하여 더 밝은색 사용.

 

<style>

.box {

  background-color: red;

  padding: 15px;

}


.box img {

  mix-blend-mode: screen;

}

</style>


<div class="box">

  <img src="https://source.unsplash.com/random" alt="랜덤이미지" width="300" height="auto">

</div>

 

<img src="https://source.unsplash.com/random" alt="랜덤이미지" width="300" height="auto">

 

결과보기

 

mix-blend-mode 정의

 

요소의 콘텐츠가 직접 상위 배경과 어떻게 혼합되어야 하는지를 지정.

 


 

1. cf.

background-blend-mode 속성 - 해당요소 각 (배경색/배경이미지)층의 혼합방식 지정.

 

2.

  • 기본값: normal
  • 상속여부: X
  • 애니가능: X
  • JS구문: object.style.mixBlendMode = "darken";

 

3.

IE 제외한 주요 최신브라우저 모두 지원.

 

4. MDN mix-blend-mode 예제보기
https://developer.mozilla.org/en-US/docs/Web/CSS/mix-blend-mode

 

 

mix-blend-mode 구문

 

selector {mix-blend-mode: normal|multiply|screen|overlay|darken|lighten|color-dodge|color-burn|hard-light|soft-light|difference|exclusion|hue|saturation|color|luminosity|initial|inherit;}

 


[속성값]

 

  • normal:  요소를 혼합 X (기본값)
  • multiply: 두 색을 곱하여 더 어두운색 생성.
  • screen: 두 색을 반전시키고 곱하여 더 밝은색 적용.
  • overlay: 주어진 조건에 따라 multiply 또는 screen을 선택하여 혼합.
  • darken: 두 색 중 더 어두운 색을 선택.
  • lighten: 두 색 중 더 밝은 색을 선택.
  • color-dodge: 두 색을 더 밝게 생성.
  • color-burn: 두 색을 더 어둡게 생성.
  • hard-light: 주어진 조건에 따라 multiply 또는 screen을 선택하여 혼합.
  • soft-light: 주어진 조건에 따라 darken 또는 lighten을 선택하여 혼합.
  • difference: 두 색의 차이를 사용하여 새로운 색을 생성.
  • exclusion: 두 색의 차이를 사용하여 더 어두운 색을 생성.
  • hue: 픽셀의 색조를 사용하여 두 색을 혼합.
  • saturation: 픽셀의 채도를 사용하여 두 색을 혼합.
  • color: 픽셀의 색조와 채도를 사용하여 두 색을 혼합.
  • luminosity: 픽셀의 밝기를 사용하여 두 색을 혼합.
  • initial: 이 속성의 기본값으로 설정.
  • inherit: 부모요소의 속성값 상속.

 

 

mix-blend-mode 예제 - 속성값별 효과 차이

 

<meta name="viewport" content="width=device-width, initial-scale=1">


<style>

.box {

  background-color: red;

  height: 5000px;

}


.box img {

  width: calc(100% / 3);

  height: auto;

  float: left;

  margin-bottom:10px;

}


.normal {mix-blend-mode: normal;}

.multiply {mix-blend-mode: multiply;}

.screen {mix-blend-mode: screen;}

.overlay {mix-blend-mode: overlay;}

.darken {mix-blend-mode: darken;}

.lighten {mix-blend-mode: lighten;}

.color-dodge {mix-blend-mode: color-dodge;}

.color-burn {mix-blend-mode: color-burn;}

.hard-light {mix-blend-mode: hard-light;}

.soft-light {mix-blend-mode: soft-light;}    

.difference {mix-blend-mode: difference;}

.exclusion {mix-blend-mode: exclusion;}

.hue {mix-blend-mode: hue;}

.saturation {mix-blend-mode: saturation;}

.color {mix-blend-mode: color;}

.luminosity {mix-blend-mode: luminosity;}

</style>


<div class="box">

  <img src="https://source.unsplash.com/random" alt="이미지" class="normal">

  <img src="https://source.unsplash.com/random" alt="이미지" class="multiply">

  <img src="https://source.unsplash.com/random" alt="이미지" class="screen">

  <img src="https://source.unsplash.com/random" alt="이미지" class="overlay">

  <img src="https://source.unsplash.com/random" alt="이미지" class="darken">

  <img src="https://source.unsplash.com/random" alt="이미지" class="lighten">

  <img src="https://source.unsplash.com/random" alt="이미지" class="color-dodge">

  <img src="https://source.unsplash.com/random" alt="이미지" class="color-burn">

  <img src="https://source.unsplash.com/random" alt="이미지" class="hard-light">

  <img src="https://source.unsplash.com/random" alt="이미지" class="soft-light">   <img src="https://source.unsplash.com/random" alt="이미지" class="difference">

  <img src="https://source.unsplash.com/random" alt="이미지" class="exclusion">

  <img src="https://source.unsplash.com/random" alt="이미지" class="hue">

  <img src="https://source.unsplash.com/random" alt="이미지" class="saturation">

  <img src="https://source.unsplash.com/random" alt="이미지" class="color">

  <img src="https://source.unsplash.com/random" alt="이미지" class="luminosity">

</div>

<script>
// class 속성의 속성값과 동일값 갖는 title 속성 생성

document.addEventListener('DOMContentLoaded', function() {

  var images = document.querySelectorAll('.box img');


  images.forEach(function(image) {

    var className = image.getAttribute('class');

    image.setAttribute('title', className);

  });

});

</script>

 

결과보기

 

mix-blend-mode 예제 - 반응형 컷아웃(cutout) 텍스트 효과

(예) 종이 오려낸 글자 효과
 

<meta name="viewport" content="width=device-width, initial-scale=1">

<style>

body {font-family: Arial, Helvetica, sans-serif;}


.box {

  background-image: url("https://source.unsplash.com/random");

  background-size: cover;

  position: relative;

  height: 300px;

}


.box .text {

  background-color: white;

  color: black;

  font-size: 10vw; 

  font-weight: bold;

  margin: 0 auto;

  padding: 10px;

  width: 80%;

  text-align: center;

  position: absolute;

  top: 50%;

  left: 50%;

  transform: translate(-50%, -50%);

  opacity:0.9;

  mix-blend-mode: screen;

}

</style>


<div class="box">

  <div class="text">Homzzang.com</div>

</div>

 

결과보기



분류 제목
text CSS - writing-mode 속성 - 텍스트 방향 가로/세로 제어. (= 글쓰기 방향 = 쓰기 모드 제…
css CSS - pointer-events 속성 - 마우스이벤트에 대한 반응 여부 (= pointer-events…
css CSS - hanging-punctuation 속성 - 문장부호 위치 지정 (= hanging-punctua…
css CSS - 자식요소 앞에 순번 붙이기 (= 번호 매기기 = 색인번호 추가 = 요소 카운팅)
selector CSS - :indeterminate 선택자 - 불확정요소 선택 (= :indeterminate선택자 = 인…
css CSS - 구글 로그인 포커스 애니 효과 (Google Logn Foucs Animation Effect) …
selector CSS - :placeholder-shown 선택자 - 플레이스홀더 텍스트 표시 중인 요소 선택 (= :pl…
css CSS - 이미지 세로 나열 (= 수직 정렬) 방법/경우/원인/이유
selector CSS - ::-webkit-scrollbar - 스크롤바 선택자 (= 스크롤바 모양 디자인 커스텀 = Cu…
box CSS - block-size 속성 - 블락 방향으로 요소 크기 지정 (= block-size속성 = 블락…
box CSS - inline-size 속성 - 인라인방향으로 요소 크기 지정 (= inline-size속성 = 인…
text CSS - overflow-wrap 속성 - 줄바꿈 위해 단어 쪼개기 (= overflow-wrap속성 = …
background CSS - Multi Background 구문 - 한번에 여러 배경 속성값 사용
selector CSS - ::placeholder 선택자 - 플레이스홀더 선택자
css CSS - 인스타그램(instagram) 배경색 효과
css CSS - currentcolor 키워드 - 현재 글자색 속성값을 그대로 사용 (= 커런트컬러 속성값)
image CSS - object-fit 속성 - 컨테이너에 맞게 '이미지/비디오' 크기 조정 방법 지정 (= obje…
image CSS - object-position 속성 - <img>/<video>가 "자체 콘텐츠 상자" 내부의 x/…
css CSS - 코드펜 스타트 코딩 버튼 테두리 효과 (Codepen Start Coding Button Bord…
css CSS - translate 속성 - 2D/3D 상 요소 위치 좌표 변경 지정 (= translate속성 =…
16/25
목록
찾아주셔서 감사합니다. Since 2012