Skip to content

Mask Image

css로 이미지를 마스킹하는 방법입니다.

데모보기

html
<!doctype html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport"
        content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
  <style>
    .icon {
      width: 100px;
      height: 100px;
      background-color: currentcolor;
      -webkit-mask-image: url('./Document 2@2x.png');
      mask-image: url('./Document 2@2x.png');
      -webkit-mask-repeat: no-repeat;
      mask-repeat: no-repeat;
      -webkit-mask-size: contain;
      mask-size: contain;
    }
  </style>
</head>
<body>
<div class="icon" style="color: #f00"></div>
</body>
</html>