29
16

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

<input type="number">のスピンボタン(上下の矢印ボタン)をCSSで非表示にする

Last updated at Posted at 2020-09-02

screen_1.png
この矢印のやつを消す方法です。

Chrome, Safari

CSS
input[type="number"]::-webkit-outer-spin-button, 
input[type="number"]::-webkit-inner-spin-button { 
  -webkit-appearance: none; 
  margin: 0; 
} 

FireFox, IE

CSS
input[type="number"] { 
  -moz-appearance:textfield; 
} 

CSSのクラスを指定して、Chrome, Safari, FireFox, IE まとめて書く

CSS
.no-spin::-webkit-inner-spin-button,
.no-spin::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
    -moz-appearance:textfield;
}
HTML
 <input type="number" class="no-spin">

CSSのクラスを指定して、!importantで最優先にしてまとめて書く

CSS
.no-spin::-webkit-inner-spin-button,
.no-spin::-webkit-outer-spin-button {
    -webkit-appearance: none !important;
    margin: 0 !important;
    -moz-appearance:textfield !important;
}

screen_2.png
消えました!

参考URL:

数字のみを入力できるフォーム(テキストボックス)を作成する
HTML5入力タイプの数値矢印をCSSクラスで非表示にしますか?
INPUTタグ type numberの時に表示される矢印ボタン(スピンボタン)を消す方法
とほほのWWW入門 > CSS - !important

29
16
4

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
29
16

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?