Can I hide the HTML5 number input’s spin box?

后端 未结 17 1631
感动是毒
感动是毒 2020-11-22 05:08

Is there a consistent way across browsers to hide the new spin boxes that some browsers (such as Chrome) render for HTML input of type number? I am looking for a CSS or Jav

17条回答
  •  说谎
    说谎 (楼主)
    2020-11-22 05:45

    To make this work in Safari I found adding !important to the webkit adjustment forces the spin button to be hidden.

    input::-webkit-outer-spin-button,
    input::-webkit-inner-spin-button {
        /* display: none; <- Crashes Chrome on hover */
        -webkit-appearance: none !important;
        margin: 0; /* <-- Apparently some margin are still there even though it's hidden */
    }
    

    I am still having trouble working out a solution for Opera as well.

提交回复
热议问题