Styling a input type=number

前端 未结 8 1681
野趣味
野趣味 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-12 23:51

    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;
    }

    or to always show:

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

    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);
    }

提交回复
热议问题