CSS - Action overlay

0

Friends I do not understand much about CSS or HTML, but I manage to get around with some things. I'm creating my site ( link ) but I'm in need of a help:

As I created in the cargocollective the template is ready, so I modified some things. I just wanted to put the overlay function in each image - that is, when I hover the mouse under it, the project name appears and it gets darker. The idea is the same as that of this site here ( link ).

Does anyone know how to do it?

    
asked by anonymous 18.01.2018 / 06:22

1 answer

0

Here is a very simple template. I preferred to do this in a simpler way with the elements separated just so you can better understand how the effect works. But it is also possible to do it using pseudo elements , attrs etc.

Take a look at the template below that I think will suit you. (be sure to study the code)

.container {
  position: relative;
  width: 200px;
}
.image {
  display: block;
  width: 100%;
  height: auto;
}
.overlay {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
  height: 100%;
  width: 100%;
  opacity: 0;
  transition: .5s ease;
  background-color: #000;
}
.text {
  color: white;
  font-size: 20px;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  -ms-transform: translate(-50%, -50%);
  text-align: center;
  background-color: #000;
  padding: 6px 10px;
  opacity: 0;
  transition: .5s ease;
}
.container:hover .overlay {
  opacity: 0.5;
}
.container:hover .text {
  opacity: 1;
  cursor: pointer;
}
.text a, a:visited, a:hover {
    color: white;
    text-decoration: none;
}
<div class="container">
  <img src="http://placecage.com/200/200"alt=" " class="image">
  <div class="overlay"></div>
  <div class="text"><a href="#">Nome do Projeto</a></div>
</div>
    
18.01.2018 / 11:29