JSFiddle - React, Tailwind, and code Playground
HTML
<div class="container">
<div class="background">
</div>
<input type="text" name="test" class="white" />
</div>
CSS
* {
box-sizing: border-box;
-webkit-box-sizing: border-box;
}
.container {
width: 200px;
height: 50px;
overflow: hidden;
position: relative;
}
.background {
position: absolute;
top: 100%;
background: red;
width: 100%;
height: 100%;
-webkit-transition: top 300ms linear;
transition: top 300ms linear
opacity: 0.5;
-webkit-opacity: 0.5
}
.background.view {
top: 0;
}
.white {
background-color: white;
}
.red {
background-color: red;
}
input {
background: transparent;
width: 100%;
height: 100%;
}
JavaScript
$("input").focus(function(e){
$(".background").addClass("view");
});
$("input").focusout(function(e){
$(".background").removeClass("view");
});