Is it possible to apply a style in the inner "up arrow" and "down arrow" of a <input type="number">
in CSS? I would like to change the background of the up arrow to blue and the down arrow to red. Any ideas?
The <input type="number"> defines a field for entering a number. Use the following attributes to specify restrictions: max - specifies the maximum value allowed. min - specifies the minimum value allowed.
Just rotate the arrow keys and set the opacity to 0. (they are now in the right place, invisible but clickable) Then set an :after and :before element over these invisible buttons. These elements can then be styled as desired.
A style attribute on an <input> tag assigns a unique style to the input control. Its value is CSS that defines the appearance of the input element.
UPDATE 17/03/2017
Original solution won't work anymore. The spinners are part of shadow dom. For now just to hide in chrome use:
input[type=number]::-webkit-inner-spin-button { -webkit-appearance: none; }
<input type="number" />
or to always show:
input[type=number]::-webkit-inner-spin-button { opacity: 1; }
<input type="number" />
You can try the following but keep in mind that works only for Chrome:
input[type=number]::-webkit-inner-spin-button { -webkit-appearance: none; cursor:pointer; display:block; width:8px; color: #333; text-align:center; position:relative; } input[type=number]::-webkit-inner-spin-button:before, input[type=number]::-webkit-inner-spin-button:after { content: "^"; position:absolute; right: 0; } input[type=number]::-webkit-inner-spin-button:before { top:0px; } input[type=number]::-webkit-inner-spin-button:after { bottom:0px; -webkit-transform: rotate(180deg); }
<input type="number" />
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With