【问题标题】:Customize appearance of up/down arrows in HTML number inputs自定义 HTML 数字输入中向上/向下箭头的外观
【发布时间】:2014-07-02 17:18:08
【问题描述】:

我有兴趣坚持使用一些基本的 HTML 元素,让用户在数字输入字段中增加值。

我知道这可以通过 Javascript/JQuery 重新布线,但是否可以在没有 JS 的情况下与这些箭头进行交互?

谢谢!

【问题讨论】:

    标签: jquery input


    【解决方案1】:

    是的,你可以(我假设只有 webkit):

    <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

    【讨论】:

    • 因为firebase不是基于-webkit引擎的
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-06-18
    • 1970-01-01
    • 1970-01-01
    • 2022-11-08
    • 2014-08-03
    • 1970-01-01
    • 2014-06-15
    相关资源
    最近更新 更多