Image Hover Text Effect

TrailFitSA101
Visitor
2 0 0

I would like to add a text hover to product images on my home page. How do I go about this. Screen Shot 2023-10-08 at 11.23.21 AM.png

Replies 2 (2)

topnewyork
Trailblazer
213 25 27

Hi @TrailFitSA101 

Adding a text hover effect to product images.

--------- HTML CODE START --------------

<div class="product">
  <img src="Image File/Link" alt="Product 1">
  <p class="product-text">Car 1 Detail Write here...........</p>
</div>

<div class="product">
  <img src="Image File/Link" alt="Product 2">
  <p class="product-text">Car 2 Details Write Here</p>
</div>

--------- HTML CODE END --------------

-------CSS CODE START --------------

<style>
.product {
  position: relative; /* Needed for absolute positioning of text */
}

.product-text {
  position: absolute; /* Position text absolutely relative to its container */
  left: 10px;
  top: 50;
  opacity: 0; /* Initially invisible */
  background-color: rgba(0, 0, 0,0.9); /* Background color for text */
  color: #fff; /* Text color */
  padding: 10px;
  text-alight: center;
  transition: opacity 0.3s ease-in; /* Smooth transition for opacity */
}

.product:hover .product-text {
  opacity: 1; /* Show text on hover */
  text-alight: center;

}

.product:hover{
filter: grayscale(20%);
opacity: 0.8;
}
</style>

-------CSS CODE END--------------

topnewyork_0-1696854626160.png

If I managed to help you then, don't forget to Like it and Mark it as Solutions.

Need a Shopify developer?
Hire us at topnewyorkwebdesign.com
For Shopify Design Changes | Shopify Custom Coding | Custom Modifications
Subscribe to our youtube channel
TrailFitSA101
Visitor
2 0 0

I am having trouble pasting this code. Can you assist me please.