<html lang="en">
<head>
    <meta charset="UTF-8">
    <script src="https://code.jquery.com/jquery-3.5.1.js" 
    integrity="sha256-QWo7LDvxbWT2tbbQ97B53yJnYU3WhH/C8ycbRAkjPDc=" 
    crossorigin="anonymous"></script>
    <link rel="stylesheet" href="style.css">
   <script src="https://kit.fontawesome.com/cb4778956c.js" crossorigin="anonymous"></script>
    <title>Search</title>
</head>
<body>
    <div class="box">
        <form name="search">
            <input type="text" class="input" name="txt">
        </form>
        <div class="btn" onclick="document.search.txt.value = ''">
            <span></span>
            <span></span>
        </div>
    </div>
   
    <script>
        $(".btn").click(function() {
            $(".input").toggleClass("click")
            $("span").toggleClass("click")
        })
    </script>
</body>
</html>
body{
    margin: 0;
    padding: 0;
    background: #0b001f;
}
.box{
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%,-50%);
}
.input {
    padding: 10px;
    width: 60px;
    height: 60px;
    background: none;
    border: 3px solid #ababff;
    border-radius: 50px;
    box-sizing: border-box;
    font-family: Comic Sans MS;
    font-size: 20px;
    color: #ababff;
    outline: none;
    transition: .8s;
    transition-delay: .2s;
}

.input.click{
    padding: 10px;
    padding-right: 60px;
    width: 300px;
    background: #221b3d;
    border-radius: 10px;
}
.btn{
    position: absolute;
    width: 60px;
    height: 60px;
    top: 0;
    right: 0;
    background: none;
    border: none;
    box-sizing: border-box;
    outline: none;
    cursor: pointer;
    transition: .2s;
}
span{
    position: absolute;
    width: 40px;
    height: 3px;
    top: 65px;
    left: 65px;
    background: #ababff;
    border-radius: 50px;
    transform: translate(-50%,-50%) rotate(45deg);
    transition: .2s;
}
span:nth-child(1).click{
    top: 50%;
    left: 50%;
    background: #a83068;
}
span:nth-child(2){
    top: 50%;
    left: 50%;
    opacity: 0;
    transition-delay: .2s;
}
span:nth-child(2).click{
    transform: translate(-50%,-50%) rotate(-45deg);
    opacity: 1;
    background: #a83068;
}

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.