0

I want to recreate this 'on-focus-blue-glow' effect on the input tag like this:

enter image description here

Here is my effort :

input:focus{
    outline-color : lightskyblue;
    outline-width : 5px;
    border : 1px solid blue;
}
input{
  padding : 0;
  line-height : 35px;
  border-radius : 5px;
  border : 1px solid black;
  width : 500px;
  }
<input type="text" />

But the outline is very small and unnoticeable. And the outline doesn't have round corners, either.
So how can I recreate the effect?

SherylHohman
  • 16,580
  • 17
  • 88
  • 94
Pranav
  • 674
  • 1
  • 6
  • 23

3 Answers3

2

Hello here I developed an example, I hope it serves you.

*, ::after, ::before {
    box-sizing: border-box;
}

input {
    margin: 0;
    font-family: inherit;
    font-size: inherit;
    line-height: inherit;
}

input {
    overflow: visible;
}

.input-focus {
    display: block;
    width: 100%;
    height: calc(1.5em + .75rem + 2px);
    padding: .375rem .75rem;
    font-size: 1rem;
    font-weight: 400;
    line-height: 1.5;
    color: #495057;
    background-color: #fff;
    background-clip: padding-box;
    border: 1px solid #ced4da;
    border-radius: .25rem;
    transition: border-color .15s ease-in-out, box-shadow .15s ease-in-out;
}

@media (prefers-reduced-motion: reduce) {
    .input-focus {
        transition: none;
    }
}

.input-focus::-ms-expand {
    background-color: transparent;
    border: 0;
}

.input-focus:-moz-focusring {
    color: transparent;
    text-shadow: 0 0 0 #495057;
}

.input-focus:focus {
    color: #495057;
    background-color: #fff;
    border-color: #80bdff;
    outline: 0;
    box-shadow: 0 0 0 .2rem rgba(0, 123, 255, .25);
}

.input-focus::-webkit-input-placeholder {
    color: #6c757d;
    opacity: 1;
}

.input-focus::-moz-placeholder {
    color: #6c757d;
    opacity: 1;
}

.input-focus:-ms-input-placeholder {
    color: #6c757d;
    opacity: 1;
}

.input-focus::-ms-input-placeholder {
    color: #6c757d;
    opacity: 1;
}

.input-focus::placeholder {
    color: #6c757d;
    opacity: 1;
}

.input-focus:disabled {
    background-color: #e9ecef;
    opacity: 1;
}

@media print {
    *, ::after, ::before {
        text-shadow: none !important;
        box-shadow: none !important;
    }
}
<input type="text" class="input-focus" aria-describedby="emailHelp">
3rdthemagical
  • 5,271
  • 18
  • 36
0

You can try using a box shadow in CSS and RGBA for a slightly transparent effect on your border's glow. That should give you the desired soft glow effect because of the blur and tiny bit of transparency in it, for example:

input:focus {
  outline-color: lightskyblue;
  outline-width: 1em;
  border: .25em solid blue;
  box-shadow: 0em 0em .75em rgba(0,0,255,0.95);
}

input {
  padding: 0;
  line-height: 35px;
  border-radius: 5px;
  border: 1px solid black;
  width: 500px;
}
<input type="text" />

With box shadow you can have setting for: v-offset h-offset blur. The third setting is what give you the fuzzy or blurred look around the border/outline. For more detailed info check out the MDN about it.

CoderLee
  • 3,079
  • 3
  • 25
  • 57
0

.input{
 padding : 0;
   line-height : 35px;
   border-radius : 5px;
        border : 1px solid black;
        width : 500px;
}

input:focus{
    outline: none !important;
    border:1px solid red;
    box-shadow: 0 0 10px #719ECE;
}
<input class="input" />
Pranav
  • 674
  • 1
  • 6
  • 23
Malith Ileperuma
  • 926
  • 11
  • 27