다음은 CSS를 사용하여 투명한 배경 텍스트로 이미지를 만드는 코드입니다 -
예시
<!DOCTYPE html> <html> <head> <meta name="viewport" imageContent="width=device-width, initial-scale=1"> <style> * { box-sizing: border-box; } body { font-family: Arial; font-size: 17px; } .imageContainer { display: inline-block; position: relative; } .imageContainer .imageContent { position: absolute; bottom: 0; background: rgba(29, 6, 43, 0.5); /* Black background with 0.5 opacity */ color: #f1f1f1; width: 100%; padding: 20px; } </style> </head> <body> <h2>Image with Transparent Text</h2> <div class="imageContainer"> <img src="https://i.picsum.photos/id/59/500/500.jpg"> <div class="imageContent"> <h1>Sceneray</h1> <h3>A beautiful scenary showing fence, barbed wires and grass</h3> </div> </div> </body> </html>
출력
위의 코드는 다음 출력을 생성합니다 -