我正在尝试设置 FF 上输入字段编号的向上和向下按钮的样式。我已经使用以下代码在 chrome 上成功实现了这一点,但我找不到任何 CSS 技巧可以在 FF 上做到这一点。
我不能使用 JS 来做到这一点。
是否可以在 FF 中使用 CSS 设置上下样式?如果是这样怎么办?- 我只需要在最新版本上实现这一点
DOM
<div class="productQty">
<span></span>
<input type="number" max="10" min="1" class="mod"/>
</div>
Run Code Online (Sandbox Code Playgroud)
CSS
input[type="number"] {
height: 30px;
width: 60px;
font-size: 18px;
position: relative;
background-color: transparent;
border: none;
-moz-appearance: textfield;
}
.productQty span {
display: block;
width: 41px;
height: 30px;
background: white;
z-index: -1;
position: absolute;
top: 0;
left: 0;
bottom: 0;
border: solid 1px #999999;
}
/* Spin Buttons modified */
input[type="number"].mod::-webkit-outer-spin-button,
input[type="number"].mod::-webkit-inner-spin-button {
-webkit-appearance: none;
background: transparent url("../img/updown.png") no-repeat center center;
width: 16px;
height: 100%;
opacity: 1; /* shows Spin Buttons per default (Chrome >= 39) */
position: absolute;
top: 0;
right: 0;
bottom: 0;
}
input[type="number"].mod::-moz-inner-spin-button:hover,
input[type="number"].mod::-moz-inner-spin-button:active{
border: none;
}
/* Override browser form filling */
input:-webkit-autofill {
background: black;
color: red;
}
Run Code Online (Sandbox Code Playgroud)
它在 chrome 上看起来如何以及它应该如何显示
它在FF 38中看起来如何
你不能直接将CSS应用到FF上的按钮,有一个关于它的错误报告: https: //bugzilla.mozilla.org/show_bug.cgi ?id=1108469
如果您不介意对包含元素应用一些 css,则可以使用:before
和:after
来覆盖自定义按钮。
div:before, div:after {
display: block;
position: absolute;
width: 14px;
height: 8px;
line-height: 8px;
background-color: #ccc;
left: 136px;
z-index: 1;
font-size: 9px;
text-align: center;
pointer-events: none;
}
div:before {
content: "+";
top: 11px;
}
div:after {
content: "-";
top: 20px;
}
Run Code Online (Sandbox Code Playgroud)
<div><input type="number" /></div>
Run Code Online (Sandbox Code Playgroud)