1
Galera mounted an input system with the same layout of android.
Everything works perfectly on input
but the input
supplier stays within a div
, because I have to add a button instead of x.
The problem is that when I get the mouse on it the border line turns blue, and when I leave it turns black again.
I need to leave it equal to the parcels input, I mean when it is clicked it has to be blue regardless if the mouse is on it or not.
Just follow my code:
$('.form_campos').on('focus blur', function(e) {
$(this).parents('.form-group').toggleClass('focused', (e.type === 'focus' || this.value.length > 0));
}).trigger('blur');
$('.form_campos_box').on('focus blur', function(e) {
$(this).parents('.box').toggleClass('focused', (e.type === 'focus' || this.value.length > 0));
}).trigger('blur');
body {
font-family: Verdana;
font-size: 12px;
}
.form-group {
position: relative;
display: flex;
height: 45px;
float: left;
margin-right: 2px;
}
.control-label {
opacity: 0.4;
pointer-events: none;
position: absolute;
transform: translate3d(5px, 22px, 0) scale(1);
transform-origin: left top;
transition: 240ms;
z-index: 2;
}
.form-group.focused .control-label {
opacity: 1;
transform: scale(0.75);
}
.form_campos {
height: 20px;
color: #484848;
z-index: 1;
align-self: flex-end;
font-size: 15px;
padding: 5px;
outline: none;
border-color: #484848;
border-style: solid;
border-bottom-width: 1px;
border-top-width: 0;
border-right-width: 0;
border-left-width: 0;
background: transparent;
}
.form_campos:hover,
.form_campos:focus {
border-color: #1E90FF;
}
.form_campos_numeros {
width: 123px;
}
/* BOX INPUT E BOTAO */
.box {
width: 250px;
display: flex;
height: 44px;
border-color: #484848;
border-style: solid;
border-bottom-width: 1px;
border-top-width: 0;
border-right-width: 0;
border-left-width: 0;
}
.box input {
outline: 0;
width: 230px;
height: 20px;
border: 0;
background: transparent;
}
.box_bt {
margin-top: 28px;
cursor: pointer;
}
.box_bt:hover {
color: #1E90FF;
}
.box:hover {
border-color: #1E90FF;
}
.box.focused .control-label {
opacity: 1;
transform: scale(0.75);
}
.form_campos_box {
color: #484848;
z-index: 1;
align-self: flex-end;
font-size: 15px;
padding: 5px;
position: relative;
display: block;
outline: none;
}
/* FIM BOX INPUT E BOTAO */
<div class='form-group'>
<label class='control-label' for='numParcelas'>PARCELAS*</label>
<input type='text' class='form_campos form_campos_numeros' id='numParcelas' name='numParcelas'>
</div>
<br><br><br><br><br><br>
<div class='box'>
<label class='control-label' for='auto'>FORNECEDOR*</label>
<input type='text' class='form_campos_box' id='auto' name='nome'>
<div class="box_bt">
<i class='demo-icon'>X</i>
</div>
</div>
Assigns directly to the
CSS
the:focus
at theinput
, withoutjQuery
. Example: https://jsfiddle.net/ojgdkjtc/– Ricardo
I don’t know, I need to keep the layout I built
– Hugo Borges