How can I make an image when passing the mouse it appears a text in the center of the image?

Asked

Viewed 131 times

1

How can I make an image when passing the mouse it appears a text in the center of the image? with css code, or other.

1 answer

4


you can do it this way:

figure {
  float: left;
  position: relative;
}

figure figcaption {
  display: none;  
  color: white;
  font-size: 24px;
  font-weight: bold;
}

.center {
  position: absolute;  
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}


figure:hover figcaption {
  display: block;
}
<figure>
  <img src="http://html5doctor.com/wp-content/uploads/2010/03/macaque.jpg" alt="Macaque in the trees">
  <figcaption class="center">A cheeky macaque, Lower Kintaganban River, Borneo.</figcaption>
</figure>

  • Thank you very much :)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.