Claymorphism Effect with HTML & CSS | Plantpot

Claymorphism Effect with HTML & CSS

Web Dev
Sponsored links

Demo

Full Screen

 

Sponsored links

 

Video

YouTube Channel

 

Sponsored links

 

Code

HTML

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <title>Claymorphism Effect with HTML & CSS</title>
    <link rel="stylesheet" type="text/css" href="style.css">
  </head>
  <body>
    <div id="container">
      <div class="box">
        <div class="square" style="--deg:30deg"></div>
        <div class="square" style="--deg:10deg"></div>
        <div class="square" style="--deg:20deg"></div>
        <div class="square" style="--deg:15deg"></div>
        <div class="square" style="--deg:15deg"></div>
        <div class="square" style="--deg:15deg"></div>
        <div class="card">
          <h1>CLAYMORPHISM</h1>
          <button type="button" name="button">Click!</button>
        </div>
      </div>
    </div>
  </body>
</html>

CSS

@charset "utf-8";
@import url('https://fonts.googleapis.com/css2?family=Nunito+Sans:wght@600;800&display=swap');
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}
html {
  font-size: 16px;
}
body {
  margin: 0;
  padding: 0;
  font-family: 'Nunito Sans', sans-serif;
}
#container {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  height: 100vh;
  overflow: scroll;
  background-image: linear-gradient(0, #fde5f2, #f685c0);
}
.box {
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
  width: 600px;
  height: 360px;
}
.card {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  width: 400px;
  height: 240px;
  border-radius: 25px;
  box-shadow: 16px 16px 32px rgba(242, 82, 165, .4),
              inset 2px 2px 8px rgba(242, 82, 165, .4),
              inset -4px -4px 8px rgba(242, 82, 165, .4),
              inset 0 4px 12px rgba(255, 255, 255, 1);
  background-color: #fff;
  -webkit-backdrop-filter: blur(5px);
  backdrop-filter: blur(5px);
}
h1 {
  margin-bottom: 20px;
  color: #02002e;
  font-weight: 800;
  font-size: 2.5rem;
  letter-spacing: 2px;
  text-shadow: 2px 2px 8px rgba(2, 0, 46, .4);
}
button {
  width: 200px;
  height: 60px;
  border: none;
  border-radius: 16px;
  box-shadow: 8px 8px 32px rgba(242, 82, 165, 1),
              inset 4px 4px 8px rgba(242, 82, 165, .5),
              inset -8px -8px 8px rgba(242, 82, 165, .5);
  background-color: #e883b7;
  color: #fff;
  font-weight: 500;
  font-size: 1.75rem;
  font-family: inherit;
  letter-spacing: 4px;
  cursor: pointer;
}
button:hover {
  box-shadow: none;
}
.square {
  position: absolute;
  border-radius: 25px;
  box-shadow: 10px 10px 32px rgba(242, 82, 165, .4),
              inset 2px 2px 8px rgba(242, 82, 165, .4),
              inset -4px -4px 8px rgba(242, 82, 165, .4),
              inset 0 5px 12px rgba(255, 255, 255, 1);
  background-color: #fff;
  -webkit-backdrop-filter: blur(5px);
  backdrop-filter: blur(5px);
}
.square:nth-child(2n+1) {
  transform: rotate(calc(-1 * var(--deg)));
  animation: bounce_odd 2s linear infinite;
}
.square:nth-child(2n) {
  transform: rotate(var(--deg));
  animation: bounce_even 2s linear infinite;
  animation-delay: 1s;
}
.square:nth-child(1) {
  top: 0;
  left: 60px;
  z-index: 999;
  width: 85px;
  height: 85px;
}
.square:nth-child(2) {
  top: 20px;
  right: 65px;
  width: 80px;
  height: 80px;
}
.square:nth-child(3) {
  top: 100px;
  right: -30px;
  width: 90px;
  height: 90px;
}
.square:nth-child(4) {
  right: 50px;
  bottom: 15px;
  width: 90px;
  height: 90px;
}
.square:nth-child(5) {
  bottom: 0;
  left: 45px;
  z-index: 999;
  width: 100px;
  height: 100px;
}
.square:nth-child(6) {
  bottom: 105px;
  left: -10px;
  width: 80px;
  height: 80px;
}
@keyframes bounce_odd {
  0% {
    transform: translateY(-5px) rotate(calc(-1 * var(--deg)));
  }
  50% {
    transform: translateY(5px) rotate(calc(-1 * var(--deg)));
  }
  100% {
    transform: translateY(-5px) rotate(calc(-1 * var(--deg)));
  }
}
@keyframes bounce_even {
  0% {
    transform: translateY(-5px) rotate(var(--deg));
  }
  50% {
    transform: translateY(5px) rotate(var(--deg));
  }
  100% {
    transform: translateY(-5px) rotate(var(--deg));
  }
}
@media screen and (max-width: 480px) {
  .box {
    width: 100%;
    height: 100vh;
  }
  .square {
    display: none;
  }
  .card {
    width: 90%;
  }
}
@media screen and (max-width: 440px) {
  h1 {
    font-size: 2rem;
  }
}
@media screen and (max-width: 380px) {
  h1 {
    font-size: 1.75rem;
  }
}
@media screen and (max-width: 320px) {
  h1 {
    font-size: 1.25rem;
  }
}