Home > Web Front-end > CSS Tutorial > How Can I Hide the Spin Box on HTML5 Number Inputs?

How Can I Hide the Spin Box on HTML5 Number Inputs?

Susan Sarandon
Release: 2024-12-19 20:41:10
Original
246 people have browsed it

How Can I Hide the Spin Box on HTML5 Number Inputs?

Hiding the HTML5 Number Input's Spin Box

Modern browsers like Chrome often display spin boxes alongside HTML5 number inputs for convenient value adjustment. However, these spin boxes can sometimes interfere with user interfaces.

One method to hide the spin boxes is through CSS:

input::-webkit-outer-spin-button,
input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

input[type=number] {
    -moz-appearance:textfield; /* Firefox */
}
Copy after login

This CSS effectively conceals the spin boxes in Webkit browsers (e.g., Chrome and Safari) while ensuring compatibility with Firefox by using the -moz-appearance:textfield property.

By implementing this CSS, you can prevent the display of up/down arrows, providing a cleaner and more streamlined user interface for your number inputs.

The above is the detailed content of How Can I Hide the Spin Box on HTML5 Number Inputs?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template