• Hello, Visitor
  • Thursday, December 12, 2024
Search Result
Home » Html Css » Card Design » Responsive card hover effect using CSS

Responsive card hover effect using CSS

View Demo:


Html Code:

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <link rel="stylesheet" href="style.css">
  <title>Document</title>
</head>
<body>
  <div class="card">
    <div class="circle">
      <div class="content">
        <h2>Pepsi Cola</h2>
        <p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Assumenda non, laborum rem impedit laudantium error doloribus sit deserunt quibusdam autem illo.</p>
        <a href="#">Buy Now</a>
      </div>
      <img src="/assets/img/can-real-sugar-reg.png" alt="">
    </div>
  </div>
</body>
</html>


Css Code:

*{
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: "Rubik", sans-serif;
}

body {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
}

.card {
  position: relative;
  width: 600px;
  height: 350px;
  border-radius: 20px;
  display: flex;
  align-items: center;
  transition: 0.5s;
}

.card .circle {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border-radius: 20px;
  overflow: hidden;
}

.card .circle::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: #d83133;
  clip-path: circle(120px at center);
  transition: 0.5s;

}

.card:hover .circle:before {
  clip-path: circle(400px at center);
  background: #0065c3;

}

.card img {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  height: 300px;
  pointer-events: none;
  transition: 0.5s;
}

.card:hover img {
  left: 72%;
  height: 300px;
} 

.card .content {
  position: relative;
  width: 50%;
  left: 20%;
  padding: 80px 20px 20px 40px;
  transition: 0.5s;
  opacity: 0;
  visibility: hidden;
}

.card:hover .content {
  left: 0;
  opacity: 1;
  visibility: visible;
}

.card .content h2 {
  color: #fff;
  text-transform: uppercase;
  font: 2em;
  line-height: 1em;
  margin-bottom: 10px;
}

.card .content p {
  color: #fff;
}

.card .content a {
  color: #fff;
  position: relative;
  padding: 10px 20px;
  border-radius: 10px;
  background: #fff;
  color: #111;
  margin-top: 20px;
  display: inline-block;
  text-decoration: none;
  font-weight: 700;
}

/ media quiery /
@media (max-width: 991px) {
  .card {
    max-width: 350px;
    align-items: flex-start;
  }

  .card:hover {
    height: 600px;
  }
  
  .card .content {
    width: 100%;
    left: 0;
    padding: 40px;
  }

  .card:hover img {
    top: 70%;
    left: 50%;
    height: 300px;
  }
}

Leave a Reply

You must Login to add a comment