Is it possible to always show up/down arrows for input “number”?

前端 未结 4 1544
感动是毒
感动是毒 2020-12-01 00:33

I want to always show up/down arrows for input \"number\" field. Is this possible? So far I haven\'t had any luck...

http://jsfiddle.net/oneeezy/qunbnL6u/

<

相关标签:
4条回答
  • 2020-12-01 01:14

    If you're trying to get the same appearance across different browsers you may be forced to use a plugin/widget or build one yourself, the main browsers all seem to implement number spinners differently.

    Try jQuery UI's spinner widget it offers a lot more versatility when it comes to styling.

    Working Example

    <p>
        <label for="spinner">Select a value:</label>
        <input id="spinner" name="value" />
    </p>
    
    $("#spinner").spinner();
    
    0 讨论(0)
  • 2020-12-01 01:21

    I tried this and it worked

    input[type=number]::-webkit-inner-spin-button {
        opacity: 1
    }
    
    </style>
    <input type="number" value="1" min="1" max="999">
    

    Found Here

    0 讨论(0)
  • 2020-12-01 01:25

    You can achieve this (in Chrome at least) by using the Opacity property:

    input[type=number]::-webkit-inner-spin-button, 
    input[type=number]::-webkit-outer-spin-button {  
    
       opacity: 1;
    
    }
    

    As stated above, this will likely only work in Chrome. So be careful using this code in the wild without a fallback for other browsers.

    0 讨论(0)
  • 2020-12-01 01:25

    If you don't mind the focus on your input, do

       document.getElementById(<id>).focus();
    
    0 讨论(0)
提交回复
热议问题