jcadima
12/1/2017 - 4:22 PM

hover text over image

https://jsfiddle.net/govdqd8y/


HTML:
<div class="img__wrap">

  <img class="img__img" src="http://placehold.it/257x200.jpg" />
  
  <div class="img__description_layer">
    <p class="img__description">This image looks super neat.</p>
  </div>
  
</div>


CSS:
/* quick reset and base styles */
* {
  margin: 0;
  padding: 0;
  border: 0;
}

html {
  font-family: helvetica, arial, sans-serif;
}

/* relevant styles */
.img__wrap {
  position: relative;
  height: 200px;
  width: 257px;
}

.img__description_layer {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(36, 62, 206, 0.6);
  color: #fff;
  visibility: hidden;
  opacity: 0;
  display: flex;
  align-items: center;
  justify-content: center;

  /* transition effect. not necessary */
  transition: opacity .2s, visibility .2s;
}

.img__wrap:hover .img__description_layer {
  visibility: visible;
  opacity: 1;
}

.img__description {
  transition: .2s;
  transform: translateY(1em);
}

.img__wrap:hover .img__description {
  transform: translateY(0);
}