0

The input-box comes with an outline that can be set to 0. It will then show an ugly border around it.

This border can be set to none as well, leaving the input box without a border.

However I'd like to put a border only on the top and bottom of the input box, but can't get it done. Any ideas?

Mukul Kant
  • 7,074
  • 5
  • 38
  • 53
Ethannn
  • 191
  • 1
  • 2
  • 16

3 Answers3

2

Apply this to your input element

input {
    border: 1px solid #000; /* this will give the input 1px black border all around */
    border-left: 0 none;
    border-right: 0 none;
}

Should do it.


Or alternatively, you can go

input {
    border: 0; /* resets default border */
    border-top: [your border styling];
    border-bottom: [your border styling];
}
kevinMario
  • 328
  • 1
  • 9
1

Just do this if you want to use the provided border..

input {
  border-left:0px;
  border-right:0px;
}

If you don't want that than use..

input {
  border-top:1px solid red;
  border-bottom:1px solid red;
  border-left:0px;
  border-right:0px;
}
Amit singh
  • 2,006
  • 1
  • 13
  • 19
0

In addition to the borders, there's also an outline added by the browser.

You can do

textarea:focus, input:focus{
    outline: 0;
}

or even

*:focus {
    outline: 0;
}

to disable this line.

Source : https://stackoverflow.com/a/3397158/3510872

Community
  • 1
  • 1
Sebastien
  • 1,014
  • 9
  • 29