How to leave the opacity of a dark image and appear the text of the figcaption in the hover?

4

Hello, I'm trying to make the image dark and the text appear when I hover over it. Can anyone help me?

<div class="efeito">
    <figure>
        <a href="#" target="_blank"><img src="comunica.jpg" ></a>
        <figcaption><span>Lorem ipsum dolor sit amet, consectetur adipiscing elit</span></figcaption>
    </figure>
</div>

CSS:

.efeito{
    -webkit-filter:opacity(100%);
}
.efeito figcaption{
    color: #000;
    position: absolute;
    opacity: 0;
}
.efeito figcaption:hover{
    opacity: 1;
}
.efeito img:hover{
    -webkit-filter:opacity(0%);
    transition: 1s;
}
    
asked by anonymous 27.10.2016 / 17:05

2 answers

2

.efeito {
  opacity: 1;
  position: relative;
}
.efeito figure .box-black {
  position: absolute;
  width: 100%;
  height: 0%;
  left: 0;
  bottom: 0;
  opacity: 0;
  z-index: 1;
  background-color: #000;
  transition: all 0.5s ease-in;
}
.efeito figure {
  position: relative;
  width: 350px;
  height: 150px;
  vertical-align: middle;
}
.efeito figcaption {
  color: #000;
  position: absolute;
  opacity: 0;
  left: 0;
  bottom: 0;
  color: #FFF;
  font-size: 20px;
  text-align: center;
  display: block;
  margin: auto;
  transform: translateY(0%);
  transition: all 0.5s ease-in .5s;
  z-index: 2;
  width: 100%;
}
.efeito:hover figure .box-black {
  opacity: 0.5;
  height: 100%;
}
.efeito:hover figure figcaption {
  opacity: 1;
  bottom: 30px;
}
<div class="efeito">
  <figure>
    <div class="box-black"></div>
    <a href="#" target="_blank">
      <img src="http://placehold.it/350x150">
    </a>
    <figcaption>
      <span>Lorem ipsum dolor sit amet, consectetur adipiscing elit</span>
    </figcaption>
  </figure>
</div>
    
27.10.2016 / 17:44
0

The problem is that the class efeito encompasses the other elements, which in turn inherit the parent element's characteristics:

.efeito{
    -webkit-filter:opacity(100%);
}
.efeito figcaption{
    color: #000;
    position: absolute;
    opacity: 0;
}
.efeito figcaption:hover{
    opacity: 1;
}
.efeito img:hover{
    -webkit-filter:opacity(0%);
    transition: 1s;
}
<div>
    <figure>
        <a href="#" target="_blank"  class="efeito"><img src="http://www.rodandopelomundo.com/wp-content/uploads/2015/12/moscow-e1449164201996.jpg" >
       </a>
       <figcaption>Lorem ipsum dolor sit amet, consectetur adipiscing elit                </figcaption>
    </figure>
</div>
    
27.10.2016 / 17:37