JSFiddle - React, Tailwind, and code Playground
by Dedi Wibisono
HTML
<script src="https://code.jquery.com/jquery-3.4.1.slim.js"></script>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.js"></script>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.css">
<div class="container">
<div class="row">
<div class="col-md-8 offset-md-2">
<div class="form-group">
<input type="text" class="form-control" placeholder="your name">
</div>
<div class="form-group">
<select name="" id="" class="form-control">
<option value="male">Male</option>
<option value="female">Female</option>
</select>
</div>
</div>
</div>
<div class="overlay-bg"></div>
</div>
CSS
.overlay-bg {
position: fixed;
top: 0;
bottom: 0;
left: 0;
right: 0;
width: 100%;
z-index: 0;
background: transparent;
pointer-events: none;
transition: .1s ease-out;
}
.is-active {
z-index: 115;
background: rgba(0, 0, 0, .35);
pointer-events: all;
cursor: pointer;
}
.dedi {
background: white;
position: relative;
z-index: 120;
}
JavaScript
$(".form-control").focusin(function() {
$(".overlay-bg").addClass('is-active')
$(this).addClass('dedi')
})
$(".form-control").focusout(function() {
$(".overlay-bg").removeClass('is-active');
$(this).removeClass('dedi')
})