Disable webkit's spin buttons on input type=number?
The below css works for both Chrome and Firefox
input[type=number]::-webkit-outer-spin-button,
input[type=number]::-webkit-inner-spin-button {
-webkit-appearance: none;
margin: 0;
}
input[type=number] {
-moz-appearance:textfield;
}
Can I hide the HTML5 number input’s spin box?
This CSS effectively hides the spin-button for webkit browsers (have tested it in Chrome 7.0.517.44 and Safari Version 5.0.2 (6533.18.5)):
input::-webkit-outer-spin-button,input::-webkit-inner-spin-button { /* display: none; <- Crashes Chrome on hover */ -webkit-appearance: none; margin: 0; /* <-- Apparently some margin are still there even though it's hidden */}
input[type=number] { -moz-appearance:textfield; /* Firefox */}
<input type="number" step="0.01" />
Hide Up & Down Arrow Buttons (Spinner) in Input Number - Firefox 29
According to this blog post, you need to set -moz-appearance:textfield;
on the input
.
input[type=number]::-webkit-outer-spin-button,input[type=number]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0;}
input[type=number] { -moz-appearance:textfield;}
<input type="number" step="0.01"/>
How to always display numerical input spinners on mobile and iPad
At some point it's hard and tricky to get a consistent result across the platforms for a native element like an input
. For this reason, I would recommend you to re-create one that 'fake' the native behaviour by using some javascript. Here is a very basic example:
const input = document.querySelector('input[type=number]')
const increment = () => {
input.value = Number(input.value) + 1
}
const decrement = () => {
input.value = Number(input.value) - 1
}
document.querySelector('.spinner.increment').addEventListener('click', increment)
document.querySelector('.spinner.decrement').addEventListener('click', decrement)
input[type=number]::-webkit-inner-spin-button,
input[type=number]::-webkit-outer-spin-button {
-webkit-appearance: none;
margin: 0;
}
.number-input {
position: relative;
width: fit-content;
}
input {
width: 60px;
}
.spinners {
position: absolute;
right: 0;
top: 50%;
display: flex;
flex-direction: column;
width: fit-content;
margin: 1px;
transform: translateY(-50%);
}
.spinner {
font-size: 7px;
border: none;
padding: 0 1px;
}
.spinner:hover {
background: lightgrey;
}
<div class="number-input">
<input type="number" name="Quantity[47]" value="0" class="qtyInputLoose" min="0" max="8">
<div class="spinners">
<button class="spinner increment">▲</button>
<button class="spinner decrement">▼</button>
</div>
</div>
Disable webkit's spin buttons on input type=“number” in AngularJS
try this works for both firefox and chrome
input[type=number]::-webkit-outer-spin-button,
input[type=number]::-webkit-inner-spin-button {
-webkit-appearance: none;
margin: 0;
}
input[type=number] {
-moz-appearance:textfield;
}
Hide HTML5 input type number arrow with a css class?
Answer
.no-spin::-webkit-inner-spin-button, .no-spin::-webkit-outer-spin-button {
-webkit-appearance: none !important;
margin: 0 !important;
}
.no-spin {
-moz-appearance:textfield !important;
}
<input type="number" class="no-spin"/>
Related Topics
Bootstrap Take Full Width for Select Drop Down
Simulate Display: Inline in React Native
Html 5 Strange Img Always Adds 3Px Margin At Bottom
What Are the Differences Between Flex-Basis and Width
Why Aren't My Grid-Template-Areas With Ascii Art Not Working
Css - Why Doesn't Percentage Height Work
Is Quoting the Value of Url() Really Necessary
Opacity CSS Not Working in Ie8
Header and Footer in Each Page in Print Mode With CSS
Click Through Div to Underlying Elements
Stretch and Scale a CSS Image in the Background - With CSS Only