devlev1980
2/23/2019 - 12:34 PM

Animated Search Input

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Search Box</title>
    <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.7.2/css/all.css" integrity="sha384-fnmOCqbTlWIlj8LyTjo7mOUStjsKC4pOpQbqyi7RrhN7udi9RwhKkMHpvLbHG9Sr" crossorigin="anonymous">
    <link rel="stylesheet" href="style.css">
</head>
<body>
    
    <div class="search-box">
        <input type="text" class="search-txt" placeholder="Search...">
        <a href="#" class="search-btn">
            <i class="fas fa-search"></i>
        </a>
    </div>
</body>
</html>
body{
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    background: #231123
}
.search-box{
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%,-50%);
    background: #82204A;
    height: 40px;
    border-radius: 40px;
    padding: 10px;
}
.search-box:hover> .search-txt{
    width: 240px;
    padding: 0 6px;
}
.search-box:hover> .search-btn{
    background-color: #CAD2C5;
    color: #231123
}
a.search-btn{
    color: #EFF7FF;
    width: 40px;
    height: 40px;
    float: right;
    border-radius: 50%;
    background: #82204A;
    display: flex;
    justify-content: center;
    align-items: center;
}
.search-txt{
    border: none;
    background: none;
    outline: none;
    float: left;
    padding: 0;
    color: #fff;
    font-size: 16px;
    line-height: 40px;
    transition: 0.4s;
    width: 0;
    transition: 0.5s;
}