Search code examples
htmlcssz-indexbox-shadow

Box Shadow works incorrectly on focus in input


<div class="group">
        <input placeholder="Номер карты" class="inpts inpt-card">
        <input placeholder="Владелец карты" class="inpts inpt-owner">
        <input placeholder="ММ/ГГ" class="inpt-mm small-inpts mmgg">
        <input placeholder="CVC" class="inpt-cvc small-inpts cvc">
        <div class="clear"></div>

All code at - https://jsfiddle.net/romariokbn/pspb5urc/

I want box-shadow on all of the focused inpts, but some sides of them is under the other inpts. Z-index changes doesnt work. How can I do it?


Solution

  • You can also just add the css property like shown below

    position: relative;

    EDIT: no jquery / js code needed imo

    .inpts:focus, .small-inpts:focus { 
        -webkit-box-shadow: 0px 0px 10px 0px #fbb040;
        -moz-box-shadow: 0px 0px 10px 0px #fbb040;
        box-shadow: 0px 0px 10px 0px #fbb040;
        z-index: 10;
        -webkit-appearance: none;
        position: relative;
    }
    

    If you really wish to affect all inputs on this page add it within "input"

    input {
        outline: none;
        position: relative;
    }
    

    Updated jsfiddle