Styling a input type=number

前端 未结 8 1661
野趣味
野趣味 2020-12-12 23:17

Is it possible to apply a style in the inner \"up arrow\" and \"down arrow\" of a in CSS? I would like to change the background of

相关标签:
8条回答
  • 2020-12-13 00:07

    The css to modify the spinner arrows is obtuse and unreliable cross-browser.

    The most stable option I have found, is to absolutely position an image with pointer-events: none; on top of the spinners.

    Untested in Edge but works in all other browsers.

    0 讨论(0)
  • 2020-12-13 00:14

    Crazy idea...

    You could play around with some pseudo elements, and create up/down arrows of css content hex codes. The only challange will be to precise the positioning of the arrow, but it may work:

    input[type="number"] {
        height: 100px;
    }
    
    .number-wrapper {
        position: relative;
    }
    
    .number-wrapper:hover:after {
        content: "\25B2";
        position: absolute;
        color: blue;
        left: 100%;
        margin-left: -17px;
        margin-top: 12%;
        font-size: 11px;
    }
    
    .number-wrapper:hover:before {
        content: "\25BC";
        position: absolute;
        color: blue;
        left: 100%;
        bottom: 0;
        margin-left: -17px;
        margin-bottom: -14%;
        font-size: 11px;
    }
    <span class='number-wrapper'>
        <input type="number" />
    </span>

    0 讨论(0)
提交回复
热议问题