How do I put these effects on images with CSS?

Asked

Viewed 108 times

0

How do I make these effects in the images leaving color and with the design of the example, and when you hover the mouse the photo gets the normal color and a text appears on the image

inserir a descrição da imagem aqui

2 answers

0

ul {
  list-style: none;
}

ul#wrap {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 830px;
  overflow: hidden;
}

ul#wrap li {
  float: left;
  width: 200px;
  /*ajusta a largura das imagens*/
  height: 200px;
  /*ajusta a altura das imagens*/
  position: relative;
}

ul#wrap li:nth-child(n) {
  margin: 0 10px 0 0;
}

ul#wrap li:nth-child(4n) {
  margin: 0 0 10px 0;
}

ul#wrap li:last-child {
  margin: 0;
}

ul#wrap li img {
  border: none;
  width: 100%;
  height: 100%;
}

ul#wrap li span {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  transition: .6s;
  /*suavidade do hover, quanto mais alto o valor mais suve*/
  background-color: rgba(0, 0, 0, 0.5);
  /*cor do efeito hover*/
  position: absolute;
  top: 0;
  left: 0;
  color: #000;
  /* cor do texto*/
  text-transform: uppercase;
}

ul#wrap li:hover span {
  background: transparent;
  color: #fff;
  /* cor do texto ao passar o mouse*/
}
<ul id="wrap">
  <li>
    <img src="https://i.imgur.com/B5OGFlF.jpg">
    <span>texto</span>
  </li>
  <li>
    <img src="https://i.imgur.com/B5OGFlF.jpg">
    <span>texto</span>
  </li>
  <li>
    <img src="https://i.imgur.com/B5OGFlF.jpg">
    <span>texto</span>
  </li>
  <li>
    <img src="https://i.imgur.com/B5OGFlF.jpg">
    <span>texto</span>
  </li>
  <li>
    <img src="https://i.imgur.com/B5OGFlF.jpg">
    <span>texto</span>
  </li>
  <li>
    <img src="https://i.imgur.com/B5OGFlF.jpg">
    <span>texto</span>
  </li>
  <li>
    <img src="https://i.imgur.com/B5OGFlF.jpg">
    <span>texto</span>
  </li>
  <li>
    <img src="https://i.imgur.com/B5OGFlF.jpg">
    <span>texto</span>
  </li>
  <li>
    <img src="https://i.imgur.com/B5OGFlF.jpg">
    <span>texto</span>
  </li>
  <li>
    <img src="https://i.imgur.com/B5OGFlF.jpg">
    <span>texto</span>
  </li>
  <li>
    <img src="https://i.imgur.com/B5OGFlF.jpg">
    <span>texto</span>
  </li>
  <li>
    <img src="https://i.imgur.com/B5OGFlF.jpg">
    <span>texto</span>
  </li>
</ul>

here a site for you to pick up the colors RGBA https://www.hexcolortool.com/

0


Hello! I tried to simplify here with only one image, from that you can do the others...

<div class="pai">
  <img src="https://i.imgur.com/cmHzq4W.jpg">
  <div class="filho">
    <span>TEXTO</span>
  </div>
</div>

CSS:

.pai {
  width: 200px;
  height: 200px;
  margin: 20px;
  position: relative;
  top: 0;
  left: 0;
  overflow: hidden;
}

.filho {
  width: 200px;
  height: 200px;
  display: inline-block;
  background: rgba(0, 100, 200, 0.5);
  text-align: center;
  position: absolute;
  top: 0;
  left: 0;
  transition-duration: 2s;
}

.filho span {
  width: 200px;
  line-height: 200px;
  color: transparent;
  transition-duration: 2s;
}

.filho:hover {
  background: none;
}

.filho:hover span {
  color: #fff;
}

Browser other questions tagged

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