Disable webkit's spin buttons on input type="number"?

pojo picture pojo · Oct 20, 2010 · Viewed 116.7k times · Source

I have a site which is primarily for mobile users but desktop too.

On Mobile Safari, using <input type="number"> works great because it brings up the numerical keyboard on input fields which should only contain numbers.

In Chrome and Safari however, using number inputs displays spin buttons at the right side of the field, which looks like crap in my design. I really don't need the buttons, because they are useless when you need to write something like a 6-digit number anyway.

Is it possible to disable this with -webkit-appearance or some other CSS trick? I have tried without much luck.

Answer

Bob Spryn picture Bob Spryn · Jan 27, 2011

I discovered that there is a second portion of the answer to this.

The first portion helped me, but I still had a space to the right of my type=number input. I had zeroed out the margin on the input, but apparently I had to zero out the margin on the spinner as well.

This fixed it:

input[type=number]::-webkit-inner-spin-button,
input[type=number]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}