To achieve this effect, utilize the pseudo classes -webkit-inner-spin-button
and -webkit-outer-spin-button
. Please note that this method is only compatible with Webkit based browsers like Chrome.
For instance:
/* Always */
input[type=number]::-webkit-inner-spin-button,
input[type=number]::-webkit-outer-spin-button {
opacity: 1;
}
If you prefer to display when hovering over the input element, modify the code as follows:
/* On hover */
input[type=number]:hover::-webkit-inner-spin-button,
input[type=number]:hover::-webkit-outer-spin-button {
opacity: 1;
}
View a live demonstration in this snippet.
To extend compatibility to other browsers, consider implementing a custom widget. An efficient option is utilizing the jQuery UI Spinner widget.