32

How do I style the text input field to make it only have a border-bottom like this one?

Expected Text Input Field

SS

dippas
  • 52,735
  • 15
  • 110
  • 120
amrjo
  • 363
  • 1
  • 3
  • 6

5 Answers5

53

Use outline:0 for chrome.. and then just set border-bottom as you like

input {
  outline: 0;
  border-width: 0 0 2px;
  border-color: blue
}
input:focus {
  border-color: green
}
<input placeholder="Text" type="text" />
dippas
  • 52,735
  • 15
  • 110
  • 120
  • 2
    Problem here is that if you do this you may break accessibility standards. From the docs: "Assigning outline a value of 0 or none will remove the browser's default focus style. If an element can be interacted with, it must have a visible focus indicator. Provide obvious focus styling if the default focus style is removed." https://developer.mozilla.org/en-US/docs/Web/CSS/outline#Accessibility_concerns – Micah Bales Jul 11 '19 at 15:42
  • @MicahBales you can fix with this: ```input:focus { border-color: green; outline: 1px dotted #000 //whatever you like }``` – dippas Jul 11 '19 at 15:55
30

Try this one

.inp {
    border:none;
    border-bottom: 1px solid #1890ff;
    padding: 5px 10px;
    outline: none;
 }

[placeholder]:focus::-webkit-input-placeholder {
    transition: text-indent 0.4s 0.4s ease; 
    text-indent: -100%;
    opacity: 1;
 }
<input class="inp" placeholder="What needs to be done?"/>
nos nart
  • 1,406
  • 1
  • 10
  • 21
  • @dippas you can add more browser CSS extension for example [Mozilla CSS extensions](https://developer.mozilla.org/en-US/docs/Web/CSS/Mozilla_Extensions) – nos nart Feb 26 '21 at 02:38
13
input {
    border: 0;
    outline: 0;
    border-bottom: 2px solid blue;
}
Daniel Diekmeier
  • 2,996
  • 15
  • 32
5
#input_Id{
   border:0px;
   border-bottom:2px solid #eee;
}
AsgarAli
  • 2,165
  • 1
  • 19
  • 32
2

input {
  border: 0;
  outline: 0;
  border-bottom: 2px solid #03a8f45e;
  font-size: 1.4rem;
  color: #ccc;
        
}
<input placeholder="Enter search query" type="text" name="fname" autofocus />
Kondal
  • 2,633
  • 4
  • 23
  • 39