gpt-4-0314· openai
Suzhen/CodeChat
.gallery{width:95%} resime text overlay ver. overlay resimden taşmasın <section…
- User
.gallery{width:95%} resime text overlay ver. overlay resimden taşmasın
- Assistant
In order to add a text overlay to the images without it overflowing, you should add the following CSS and modify the
overlayclass in the HTML as follows:CSS:
.gallery { width: 95%; } .overlay { position: relative; } .overlay-text { position: absolute; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0, 0, 0, 0.5); display: flex; align-items: center; justify-content: center; color: #fff; opacity: 0; transition: 0.5s ease-in-out; } .overlay:hover .overlay-text { opacity: 1; }HTML:
<section class="gallery"> <div class="container"> <div class="row"> <div class="col-4 col-md-4 p-1 col-lg-4 overlay"> <img src="img/destination-2.jpg" class="img-fluid" alt="image"> <div class="overlay-text">Your Text Here</div> </div> <div class="col-4 col-md-4 p-1 col-lg-4 overlay"> <img src="img/destination-3.jpg" class="img-fluid" alt="image"> <div class="overlay-text">Your Text Here</div> </div> <div class="col-4 col-md-4 p-1 col-lg-4 overlay"> <img src="img/destination-2.jpg" class="img-fluid" alt="image"> <div class="overlay-text">Your Text Here</div> </div> <div class="col-6 col-md-6 p-1 col-lg-6 overlay"> <img src="img/destination-3.jpg" class="img-fluid" alt="image"> <div class="overlay-text">Your Text Here</div> </div> <div class="col-6 col-md-6 p-1 col-lg-6 overlay"> <img src="img/destination-2.jpg" class="img-fluid" alt="image"> <div class="overlay-text">Your Text Here</div> </div> </div> </div> </section>