4

I'd like to remove left, right and up outlines, leaving only the bottom outline.

for example:

 input
_______

I know we can remove ALL outlines using this way:

<input style="outline: none" >

Is there any way to keep the bottom outline?

Amy
  • 41
  • 2

3 Answers3

3

You can't do that. According to w3schools

Outlines differ from borders! Unlike border, the outline is drawn outside the element's border

It applies to the whole element.

You could try box-shadow perhaps

input {outline: none; border:none; border-bottom: 1px solid orange;}
input:focus{box-shadow: 0 1px 0 0 blue;}
<input type="text" placeholder="name">
Viira
  • 3,805
  • 3
  • 16
  • 39
  • 1
    Why do they have to make it so complicated, I mean why can't border-bottom work with outline: none; on input-focus. I only want lines when in focus. The amount of time I lose every time for little things like that is atrocious. Anyway, thanks for your help! ;) – Shuryno Mar 08 '22 at 14:20
1

You can't do that using outlines, but you can do it using borders.

just Add border-bottom in input field and changed border color on Hover and Focus

input{
/* Extra css */
height: 42px;
padding: 6px 12px;
background-color: #eee;
border-radius: 0px;

/* Actual css */
border: 0px;
outline: 0px;
border-bottom: 2px blue solid;
}

/* CSS for Hover */
input:hover{
border-bottom: 2px red solid;
}

/* CSS for Focus */ 
input:focus{
border-bottom: 2px green solid;
}
<input type="text" placeholder="Enter your Name...">
Karar Barcha
  • 406
  • 4
  • 11
0

the Outline CSS code has the following properties:

outline-style
outline-color
outline-width
outline-offset
outline

you can't keep the outline bottom and remove the remaining (top, left and right.) you have to keep all or remove all. but you can use border instead, like this:

.class-name {border-bottom: solid 2px white;}
Abramo
  • 87
  • 2
  • 12