JSFiddle - React, Tailwind, and code Playground
by levchenko_d
HTML
<form>
<label>
<input type="text" placeholder="Search"/>
<button></button>
</label>
</form>
CSS
body{
background: #f2f2f2;
margin: 0;
}
form{
width: 100%;
height: 50px;
background: white;
}
label{
display: block;
width: 50%;
height: 50px;
margin: 0 auto;
overflow: hidden;
position: relative;
}
input{
border: none;
outline: none;
padding: 16px 15px;
width: 100%;
}
button{
background: url('http://www.jobbafrisk.se/sites/all/themes/jobbafrisk/images/sbicon.png') no-repeat right center;
background-size: 18px;
border: none;
padding: 10px;
margin: 0;
outline: none;
position: absolute;
opacity: 0.8;
top: 15px;
right: -20px;
-webkit-transition: right 0.2s ease-out;
-moz-transition: right 0.2s ease-out;
transition: right 0.2s ease-out;
cursor: pointer;
}
input:focus ~ button, button:active{
right: 13px;
}
button:hover{
opacity: 1;
}
button:active{
opacity: 0.8;
}
JavaScript
document.querySelector('button').onclick = function(e){ e.preventDefault(); };