-1

I have a problem. When I hover the mouse over in the picture I see too dark text. I want to white text in this picture. You'll solve this?

#tile:hover {
  cursor: pointer;
  opacity: 0.1;
}

#tile .text {
  position:relative;
  bottom:30px;
  visibility: hidden;
}

#tile:hover .text {
  visibility: visible;
  text-align: center;
  margin-top: -80px;
  color: white;
  cursor: pointer;
}
<div id = "container">
  <div class = "square">
      <div id="tile"><img src="image/shampoo.png"><p class="text">Shampoo</p></div>
  </div>
</div>

Without text

enter image description here

With text but dark text

enter image description here

Manish Patel
  • 3,648
  • 1
  • 14
  • 22
Ania
  • 292
  • 4
  • 11

1 Answers1

0

I have added a little CSS to make it work in this demo, but basically you will need to target the image directly like this so that it doesn't affect your text as well:

#tile:hover img {opacity: .1;}

#container {
  background: black;
  width: 200px;
}

#tile:hover
{
  cursor: pointer;
}

#tile:hover img /* Only add opacity to image */
{
  opacity: 0.1;
}

#tile .text 
{
  position:relative;
  bottom:30px;
  visibility: hidden;
}

#tile:hover .text
{
  visibility: visible;
  text-align: center;
  /*margin-top: -80px;*/
  color: white;
  cursor: pointer;
}
<div id = "container">
  <div class = "square">
    <div id="tile"><img src="http://placehold.it/200x200"><p class="text">Shampoo</p></div>
  </div>
</div>
Jonathan
  • 6,507
  • 5
  • 37
  • 47