JSFiddle - React, Tailwind, and code Playground
by Felype Rennan
HTML
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css">
<div class="double-search">
<div class="input-container">
<input type="text" placeholder="Campo da esquerda" class="left" />
<input type="text" placeholder="Campo da direita" class="right" />
</div>
<button class="search"><i class="fa fa-search"></i></button>
</div>
SCSS
$btn-width: 40px;
$ds-h-padding: 8px;
$ds-total-h-padding: 16px;
$ds-height: calc( 1em + 16px );
.double-search {
position: relative;
width: 100%;
height: $ds-height;
.input-container {
height: $ds-height;
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: $btn-width;
display: flex;
overflow: hidden;
input {
width: 50%;
height: 100%;
margin: 0;
padding: 0 8px;
height: $ds-height;
line-height: $ds-height;
position: absolute;
z-index: 2;
&.left {
right: 50%;
left: 0;
transition: 250ms ease-in-out;
background: #f5f5f5;
&:focus, &:not(:empty) {
right:20%;
width: 80%;
z-index: 3;
background: white;
+ .right {
left: 82%;
}
}
}
&.right {
right: 0;
left: 50%;
transition: 250ms ease-in-out;
background: #f5f5f5;
&:focus, &:not(:empty) {
left:20%;
width: 80%;
z-index: 3;
background: white;
}
}
}
}
.search {
position: absolute;
background: black;
display: block;
right: 0;
top: 0;
outline: none;
color: white;
width: $btn-width;
height: $ds-height;
transition: 100ms ease-out;
border: 0;
cursor: pointer;
&:hover {
background: #00809C;
color: white;
}
}
}