CSS - Overlay action

Asked

Viewed 1,273 times

0

Friends I am not very good with CSS or HTML, but I can manage with some things. I am creating my site (https://girundi.com/) just that they need a help:

As I created in cargocollective the template is ready, so I modified some things. Only that I wanted to put on each image the overlay function - that is, when you hover over it, the name of the project appears and it gets darker. The idea is just like this site here (http://www.brunooppido.com/).

Someone knows how I do?

  • 1

    I saw what you’re getting at, but you can post at least some functional code (part of HTML, CSS and JS if necessary) so we can give our opinion?

  • 1

    Read about the effect Hover of the CSS.

1 answer

0


It follows a very simple model. I preferred to make it simpler this way with the separate elements just so you understand better how the effect works. But it is also possible to do using pseudo Elements, attrs etc..

Take a look at the model 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>

  • +1 Hello my dear! First of all thanks for the help. With I don’t get many on this site, it took me a while to see it. I contacted a programmer I know and he did the freelance for me. Take a look at it later! Well, I gave a study and talking to him I saw that the platform that hosted the site does not have an HTML version as I thought what would make it easier for me to create the code. That way if I just added overly as HTML code would never work. To do this it was necessary to copy the code of the page and write it all over again to have left in HTML and facilitate the job

  • @Nice Williamgirundi that worked! Each framework works one way, sometimes even complicates. But try not to be in the hands of a programmer, study hard and learn to do it yourself. Success!

Browser other questions tagged

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