프론트엔드/컴포넌트

배경이 비취는 투명 텍스트 효과 만들기

syleemomo 2023. 4. 14. 17:07
728x90
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>design practice</title>
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css" integrity="sha512-iecdLmaskl7CVkqkXNQ/ZH/XLlvWZOJyj7Yy7tcenmpD1ypASozpmT/E0iPtmFIB46ZmdtAc9eNBvH0H/ZpiBw==" crossorigin="anonymous" referrerpolicy="no-referrer" />
  <link rel="stylesheet" href="style.css">
</head>
<body>
  <div class="bg">This is Life !</div>
  
  <script src="app.js"></script>
</body>
</html>
body{
  margin: 0; padding: 0;
}
.bg{
  width: 100vw;
  height: 100vh;
  background-image: url(https://www.yachtandboat.com/wp-content/uploads/2018/12/hero-image-2.jpg);  
  background-repeat: no-repeat;
  background-size: cover;
  background-position: center;
  position: fixed; /* 백그라운드 배경 고정 */

  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 20rem;
  font-weight: bold;

  /* 투명 텍스트 효과 */
  -webkit-text-fill-color: transparent;
  -webkit-background-clip: text;
}
728x90