How to make a box and a href in this box

Asked

Viewed 70 times

1

Well I wanted to create a box where when clicked a Hoover appears and it has a link: ex: inserir a descrição da imagem aqui

with Hoover: inserir a descrição da imagem aqui

as is mine so far :

inserir a descrição da imagem aqui

html code:

 <section id="promo">
       <?php
                $consulta = $pdo->prepare("SELECT * FROM produtohome");
                $consulta -> execute();

                $linhas = $consulta -> rowCount();

                foreach($consulta as $mostra):
            ?>
            <div class="card">
              <img class="skin"src="images/<?= $mostra['produto_img']?>" alt="Nome da Empresa: <?= $mostra['produto_nome']?>" title="Nome da Empresa: <?= $mostra['produto_nome']?>">
              <h1 class="color-white text-center font-text-light-med font-weight-heavy bgcolor-black"><?= $mostra['produto_nome']?></h1>
              <p class="bgcolor-gray text-center color-dark-full font-text-light-med">Por: R$ <?= number_format($mostra['produto_preco'], 2,',','.')?></p>
              <button class="bgcolor-red text-center btn"><a href="comprar.php?prod=<?= $mostra['produto_id']?>">Comprar</a></button>
            </div>
            <?php endforeach; ?>

        </section>

css:

.card {
  box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2);
  max-width: 300px;
  margin: auto;
  height: 300px;
  text-align: center;
  font-family: arial;
}
.skin {
  box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2);
  max-width: 300px;
  margin: auto;
  text-align: center;
  font-family: arial;
}
.price {
  color: grey;
  font-size: 22px;
}

.card button {
  border: none;
  outline: 0;
  margin-top: 10px;
  height: 30px;
  color: black;
  background-color: #fff;
  border-top: 1px solid rgba(0, 0, 0, 0.2);;
  border-bottom: 1px solid rgba(0, 0, 0, 0.2);;
  text-align: center;
  cursor: pointer;
  width: 100%;
  font-size: 18px;
}

.card button:hover {
  opacity: 0.7;
}

1 answer

1


Dude I don’t know if this is exactly what you need, but I put some attributes on the card to make the red "edge" with a outline. And the internal content I created a div which remains hidden and :hover in the card this content appears.

See how it looked in the example.

.card {
  box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2);
  max-width: 300px;
  margin: auto;
  height: 300px;
  text-align: center;
  font-family: arial;
  box-sizing: border-box;
}
.card:hover {
box-shadow: 0 8px 12px 0 rgba(0, 0, 0, 0.2);
  outline: 4px solid red;
}
.skin {
  box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2);
  max-width: 300px;
  margin: auto;
  text-align: center;
  font-family: arial;
}
.price {
  color: grey;
  font-size: 22px;
}

.card button {
  border: none;
  outline: 0;
  margin-top: 10px;
  height: 30px;
  color: black;
  background-color: #fff;
  border-top: 1px solid rgba(0, 0, 0, 0.2);
  border-bottom: 1px solid rgba(0, 0, 0, 0.2);
  text-align: center;
  cursor: pointer;
  width: 100%;
  font-size: 18px;
}

.card button:hover {
  opacity: 0.7;
}

.card .info {
  opacity: 0;
  height: 0px;
  line-height: 0px;
  background-color: #000;
  color: #fff;
  text-align: center;
  transition: all 500ms;
}
.card:hover .info {
  opacity: 1;
  height: 50px;
  line-height: 50px;
}
<section id="promo">

    <div class="card">
      <img class="skin"src="https://placecage.com/100/100" alt="Nome da Empresa: 
      <?= $mostra['produto_nome']?>" title="Nome da Empresa: <?= $mostra['produto_nome']?>">
      <div class="info">
        <span>conteúdo</span>
      </div>
      <h1 class="color-white text-center font-text-light-med font-weight-heavy bgcolor-black"><?= $mostra['produto_nome']?></h1>
      <p class="bgcolor-gray text-center color-dark-full font-text-light-med">Por: R$ <?= number_format($mostra['produto_preco'], 2,',','.')?></p>
      <button class="bgcolor-red text-center btn"><a href="comprar.php?prod=<?= $mostra['produto_id']?>">Comprar</a></button>
    </div>
    <?php endforeach; ?>

</section>

  • was just that same man vlw

  • 1

    @Gabrielcosta good that helped, good luck there!

  • opa mano I’ll create a new question about by a counter on top of this image I’m trying to, but I’m getting and I send you the link you could give me a help?

  • @Gabrielcosta I don’t know much about JS, actually almost nothing, but what you need help with the layout I help you yes

  • vlw I’m going to do a better search, @hugocsl and about this code I tried to put and it looked exactly like this http://prntscr.com/ky5tm3, you called jquery?

  • No Hoover appears when you click or edge.

  • @Gabrielcosta this CSS that works only in :Hover, that is when the user hovers over the card. If you want to change the class when it clicks with the mouse, then only with jquery or JS... This is exactly what you want, that only when the guy clicks on the card appears the information?

  • was right, but like the Hoover when it passes the mouse is not going the Hoover and I used the same code.

  • ta getting static and without Hoover as in this print ; prntscr.com/ky5tm3

  • Cara se aqui funciona eh para funcionar no seu código tb. Vc esta usando algum outro CSS? Tentar colocar esse código em outro html para ver funciona. If it works, eh pq has some CSS on your current page that is interfering with this new CSS. Remove unnecessary css etc... You’re wearing a bootstrap?

  • I’ll test, I’m not wearing bootstrap no.

Show 6 more comments

Browser other questions tagged

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