You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Bootstrap 5.2下移除数字输入框箭头时,如何在CSS中正确覆盖-moz-appearance属性?

Fixing Bootstrap 5.2 Number Input Arrows in Firefox

Let’s get that Firefox number input arrow issue sorted out! The root problem here is Bootstrap 5.2’s default styles applying appearance: none; to number inputs, which is overriding your -moz-appearance: textfield; rule—exactly what you spotted in dev tools.

Here are two reliable ways to fix this:

Bootstrap typically applies styles to inputs via the .form-control class. We can create a more specific selector to override its default appearance rule without relying on !important:

/* Chrome, Safari, Edge, Opera */
input::-webkit-outer-spin-button,
input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

/* Firefox - override Bootstrap's default appearance rule */
input[type=number].form-control {
  -moz-appearance: textfield;
  appearance: textfield; /* Reset global appearance to textfield for Firefox */
}

This works because the selector input[type=number].form-control has higher specificity than Bootstrap’s .form-control rule, so your styles will take precedence.

Option 2: Use !important (Quick Fix)

If you don’t want to tie the rule to the .form-control class, you can use !important to force your styles to override Bootstrap’s:

/* Chrome, Safari, Edge, Opera */
input::-webkit-outer-spin-button,
input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

/* Firefox - force override with !important */
input[type=number] {
  -moz-appearance: textfield !important;
  appearance: textfield !important;
}

Just note that overusing !important can make CSS harder to maintain long-term, so the first option is preferred when possible.

After updating your CSS, refresh Firefox and you’ll see those number input arrows are gone, matching the behavior in Chrome!

内容的提问来源于stack exchange,提问作者randoo

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.29 00:24:07