How can I make an image when I move the mouse, does a text appear in the center of the image?

1

How can I make an image when I move the mouse, does a text appear in the center of the image? with css code, or other.

    
asked by anonymous 30.05.2016 / 14:43

1 answer

4

you can do as follows:

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>
    
30.05.2016 / 14:58