JSFiddle - React, Tailwind, and code Playground

by Vishnuprasad ps

HTML

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<button class="zoom-close">
  <div class="zoom"><span class="zoom-inner"></span></div>
</button>

CSS

body {
  background: red;
}

.zoom-close {
  background: #eee;
  border: 0;
  width: 32px;
  height: 32px;
  padding: 8px 8px 15px;
  cursor: pointer;
  outline: 0;
  border-radius: 0;
  transition: all 0.5s ease;
}
.zoom-close.transform {
  border-radius: 100%;
  transition: all 0.5s ease;
}
.zoom-close.transform .zoom-inner {
  opacity: 0;
  transition: all 0.5s ease;
}
.zoom-close.transform .zoom {
  border: 0;
}
.zoom-close.transform .zoom:before {
    width: 2px;
    height: 17px;
    top: 1px;
    left: 7px;
    transform: rotate(45deg);
    transition: all 0.5s ease;
}
.zoom-close.transform .zoom:after {
    height: 2px;
    width: 17px;
    top: 9px;
    left: -1px;
    transform: rotate(45deg);
    transition: all 0.5s ease;
}

.zoom {
  width: 10px;
  height: 10px;
  border-radius: 8px;
  position: relative;
  border: 2px solid #000;
}

.zoom:before {
  content: '';
  width: 2px;
  height: 8px;
  background: #000;
  display: block;
  top: 1px;
  left: 4px;
  position: absolute;
  transition: all 0.5s ease;
}

.zoom-inner {
  width: 8px;
  height: 3px;
  display: block;
  background: #000;
  position: absolute;
  top: 10px;
  left: 7px;
  transform: rotate(45deg);
  -webkit-transform: rotate(45deg);
  transition: all 0.5s ease;
}

.zoom:after {
  content: '';
  height: 2px;
  width: 8px;
  background: #000;
  display: block;
  top: 4px;
  left: 1px;
  position: absolute;
  transition: all 0.5s ease;
}

JavaScript

$(function() {
  $(".zoom-close").on("click", function() {
    $(".zoom-close").toggleClass("transform", 1000);
  });
});