本文介绍了是否可以始终为输入“数字"显示向上/向下箭头?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想始终为输入数字"字段显示向上/向下箭头.这可能吗?到目前为止,我还没有运气...

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

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/

HTML:

<input type="number" />

CSS:

input[type=number]::-webkit-inner-spin-button,
input[type=number]::-webkit-outer-spin-button {

   -webkit-appearance: "Always Show Up/Down Arrows";

}

推荐答案

您可以通过使用 Opacity 属性来实现这一点(至少在 Chrome 中):

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;

}

如上所述,这可能仅适用于 Chrome.所以在野外使用此代码时要小心,不要为其他浏览器提供后备.

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.

这篇关于是否可以始终为输入“数字"显示向上/向下箭头?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-09 04:47