Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Customize appearance of up/down arrows in HTML number inputs

Tags:

jquery

input

I'm interested in sticking with some basic HTML elements to let users increment the value in a number input field.

I know this is possible through Javascript/JQuery rewiring, but is it possible to interact with these arrows without JS?

Up/down arrows

Thanks!

like image 644
charliesneath Avatar asked Jul 02 '14 17:07

charliesneath


People also ask

How do I hide input field numbers in Arrows?

Using inputmode=”numeric” attribute you can find an input box without an arrow.

How do you limit input numbers in HTML?

The HTML <input> tag is used to get user input in HTML. To give a limit to the input field, use the min and max attributes, which is to specify a maximum and minimum value for an input field respectively. To limit the number of characters, use the maxlength attribute.


1 Answers

Yes, you can (webkit only I assume):

<style>
input[type=number] {
    height: 30px;
    line-height: 30px;
    font-size: 16px;
    padding: 0 8px;
}
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]:hover::-webkit-inner-spin-button { 
    background: #eee url('http://i.stack.imgur.com/YYySO.png') no-repeat 50% 50%;  
    width: 14px;
    height: 14px;
    padding: 4px;
    position: relative;
    right: 4px;
    border-radius: 28px;
}
</style>

<input type="number" value="0">

See JSFiddle method 1

See JSFiddle method 2

Reference

bg image

like image 147
Justin Avatar answered Nov 15 '22 21:11

Justin