Implementing the new Twitter icon [X] using HTML/CSS

picture[1]-Implementing the new Twitter icon [X] using HTML/CSS - PANDA-PANDA

In this article, we will introduce the method of creating the new Twitter icon [X] using HTML/CSS. Below is the specific code to create a button with the [X] icon entirely using HTML and CSS:

HTML

<button class="button">
  <div class="bloom-container">
    <div class="button-container-main">
      <div class="button-inner">
        <div class="back"></div>
        <div class="front">
          <svg
            xmlns="http://www.w3.org/2000/svg"
            viewBox="0 0 50 50"
            width="50px"
            height="50px"
          >
            <path
              d="M 5.9199219 6 L 20.582031 27.375 L 6.2304688 44 L 9.4101562 44 L 21.986328 29.421875 L 31.986328 44 L 44 44 L 28.681641 21.669922 L 42.199219 6 L 39.029297 6 L 27.275391 19.617188 L 17.933594 6 L 5.9199219 6 z M 9.7167969 8 L 16.880859 8 L 40.203125 42 L 33.039062 42 L 9.7167969 8 z"
            ></path>
          </svg>
        </div>
      </div>
      <div class="button-glass">
        <div class="back"></div>
        <div class="front"></div>
      </div>
    </div>
    <div class="bloom bloom1"></div>
    <div class="bloom bloom2"></div>
  </div>
</button>

CSS

.button {
  background: none;
  border: none;
}

.button .bloom-container {
  position: relative;
  transition: all 0.2s ease-in-out;
  border: none;
  background: none;
}

.button .bloom-container .button-container-main {
  width: 110px;
  aspect-ratio: 1;
  border-radius: 50%;
  overflow: hidden;
  position: relative;
  display: grid;
  place-content: center;
  border-right: 5px solid white;
  border-left: 5px solid rgba(128, 128, 128, 0.147);
  transform: rotate(-20deg);
  transition: all 0.5s ease-in-out;
}

.button .bloom-container .button-container-main .button-inner {
  height: 60px;
  aspect-ratio: 1;
  border-radius: 50%;
  position: relative;
  box-shadow: rgba(100, 100, 111, 0.5) -10px 5px 10px 0px;
  transition: all 0.5s ease-in-out;
}

.button .bloom-container .button-container-main .button-inner .back {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: linear-gradient(
    60deg,
    rgb(245, 255, 255) 0%,
    rgb(185, 225, 200) 100%
  );
}

.button .bloom-container .button-container-main .button-inner .front {
  position: absolute;
  inset: 5px;
  border-radius: 50%;
  background: linear-gradient(60deg, rgb(0, 0, 0));
  display: grid;
  place-content: center;
  transform: rotate(20deg);
}

.button .bloom-container .button-container-main .button-inner .front .svg {
  fill: #ffffff;
  opacity: 0.5;
  width: 30px;
  aspect-ratio: 1;
  transition: all 0.2s ease-in;
}

.button .bloom-container .button-container-main .button-glass {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0) 0%,
    rgba(255, 255, 255, 0.888) 100%
  );
  transform: translate(0%, -50%) rotate(0deg);
  transform-origin: bottom center;
  transition: all 0.5s ease-in-out;
}

.button .bloom-container .bloom {
  height: 1px;
  width: 1px;
  position: absolute;
  background: white;
}

.button .bloom-container .bloom1 {
  top: 10px;
  right: 20px;
  box-shadow: rgb(255, 255, 255) 0px 0px 10px 10px,
    rgb(255, 255, 255) 0px 0px 20px 20px;
}

.button .bloom-container .bloom2 {
  bottom: 10px;
  left: 20px;
  box-shadow: rgba(255, 255, 255, 0.5) 0px 0px 10px 10px,
    rgba(255, 255, 255, 0.5) 0px 0px 30px 20px;
}

.button .bloom-container:hover {
  transform: scale(1.1);
}

.button .bloom-container:hover .button-container-main .button-glass {
  transform: translate(0%, -40%);
}

.button
  .bloom-container:hover
  .button-container-main
  .button-inner
  .front
  .svg {
  opacity: 1;
  filter: drop-shadow(0 0 10px white);
}

.button .bloom-container:active {
  transform: scale(0.7);
}

.button .bloom-container:active .button-container-main .button-inner {
  transform: scale(1.2);
}

HTML & CSS

<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    .button {
      background: none;
      border: none;
    }

    .button .bloom-container {
      position: relative;
      transition: all 0.2s ease-in-out;
      border: none;
      background: none;
    }

    .button .bloom-container .button-container-main {
      width: 110px;
      aspect-ratio: 1;
      border-radius: 50%;
      overflow: hidden;
      position: relative;
      display: grid;
      place-content: center;
      border-right: 5px solid white;
      border-left: 5px solid rgba(128, 128, 128, 0.147);
      transform: rotate(-20deg);
      transition: all 0.5s ease-in-out;
    }

    .button .bloom-container .button-container-main .button-inner {
      height: 60px;
      aspect-ratio: 1;
      border-radius: 50%;
      position: relative;
      box-shadow: rgba(100, 100, 111, 0.5) -10px 5px 10px 0px;
      transition: all 0.5s ease-in-out;
    }

    .button .bloom-container .button-container-main .button-inner .back {
      position: absolute;
      inset: 0;
      border-radius: 50%;
      background: linear-gradient(60deg,
          rgb(245, 255, 255) 0%,
          rgb(185, 225, 200) 100%);
    }

    .button .bloom-container .button-container-main .button-inner .front {
      position: absolute;
      inset: 5px;
      border-radius: 50%;
      background: linear-gradient(60deg, rgb(0, 0, 0));
      display: grid;
      place-content: center;
      transform: rotate(20deg);
    }

    .button .bloom-container .button-container-main .button-inner .front .svg {
      fill: #ffffff;
      opacity: 0.5;
      width: 30px;
      aspect-ratio: 1;
      transition: all 0.2s ease-in;
    }

    .button .bloom-container .button-container-main .button-glass {
      position: absolute;
      inset: 0;
      background: linear-gradient(90deg,
          rgba(255, 255, 255, 0) 0%,
          rgba(255, 255, 255, 0.888) 100%);
      transform: translate(0%, -50%) rotate(0deg);
      transform-origin: bottom center;
      transition: all 0.5s ease-in-out;
    }

    .button .bloom-container .bloom {
      height: 1px;
      width: 1px;
      position: absolute;
      background: white;
    }

    .button .bloom-container .bloom1 {
      top: 10px;
      right: 20px;
      box-shadow: rgb(255, 255, 255) 0px 0px 10px 10px,
        rgb(255, 255, 255) 0px 0px 20px 20px;
    }

    .button .bloom-container .bloom2 {
      bottom: 10px;
      left: 20px;
      box-shadow: rgba(255, 255, 255, 0.5) 0px 0px 10px 10px,
        rgba(255, 255, 255, 0.5) 0px 0px 30px 20px;
    }

    .button .bloom-container:hover {
      transform: scale(1.1);
    }

    .button .bloom-container:hover .button-container-main .button-glass {
      transform: translate(0%, -40%);
    }

    .button .bloom-container:hover .button-container-main .button-inner .front .svg {
      opacity: 1;
      filter: drop-shadow(0 0 10px white);
    }

    .button .bloom-container:active {
      transform: scale(0.7);
    }

    .button .bloom-container:active .button-container-main .button-inner {
      transform: scale(1.2);
    }
  </style>
</head>

<body>
  <button class="button">
    <div class="bloom-container">
      <div class="button-container-main">
        <div class="button-inner">
          <div class="back"></div>
          <div class="front">
            <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 50 50" width="50px" height="50px">
              <path
                d="M 5.9199219 6 L 20.582031 27.375 L 6.2304688 44 L 9.4101562 44 L 21.986328 29.421875 L 31.986328 44 L 44 44 L 28.681641 21.669922 L 42.199219 6 L 39.029297 6 L 27.275391 19.617188 L 17.933594 6 L 5.9199219 6 z M 9.7167969 8 L 16.880859 8 L 40.203125 42 L 33.039062 42 L 9.7167969 8 z">
              </path>
            </svg>
          </div>
        </div>
        <div class="button-glass">
          <div class="back"></div>
          <div class="front"></div>
        </div>
      </div>
      <div class="bloom bloom1"></div>
      <div class="bloom bloom2"></div>
    </div>
  </button>

</body>

</html>
THE END
Like 7 Share
comment
 avatar
Your valuable insights are welcome!
Submit
 avatar

Nickname

cancel
NicknameSmiliesCodeimage

    No comments yet