
w3.css
투명한 텍스트가 포함된 이미지
CSS를 사용하여 투명(투명) 배경 텍스트가 있는 이미지를 만드는 방법을 알아보자.
투명한 이미지 텍스트를 만드는 방법
1단계) HTML 추가
<div class="container"> <img src="notebook.jpg" alt="Notebook" style="width:100%;"> <div class="content"> <h1>Heading</h1> <p>Lorem ipsum..</p> </div> </div>
2단계) CSS 추가
.container { position: relative; max-width: 800px; /* Maximum width */ margin: 0 auto; /* Center it */ } .container .content { position: absolute; /* Position the background text */ bottom: 0; /* At the bottom. Use top:0 to append it to the top */ background: rgb(0, 0, 0); /* Fallback color */ background: rgba(0, 0, 0, 0.5); /* Black background with 0.5 opacity */ color: #f1f1f1; /* Grey text */ width: 100%; /* Full width */ padding: 20px; /* Some padding */ }
기본 예시
예제 보기참고
W3C School - How TO - Image with Transparent Text