【CSS】input type numberのスピンボタンを削除する方法

先日、ディレクターからinput type numberの矢印ボタンを削除できるかと聞かれたので、CSSで対応できると伝えた。

その時のコードをメモしておく。

input type numberのスピンボタン(フィールドエリアの右側に表示される矢印のボタンのこと)を削除する方法はCSSで下記のコードを設定すると消える。

表示結果

See the Pen Jjbmorg by 山崎毅 (@nbudjgzu) on CodePen.

HTML

<input type="number">

CSS(SCSS)

input[type="number"] {
  //FireFox, IE
  -moz-appearance:textfield;
  //Chrome, Safari
  &::-webkit-outer-spin-button,
  &::-webkit-inner-spin-button {
    margin: 0;
    -webkit-appearance: none;
    appearance: none;
  }
}
(Visited 1,732 times, 1 visits today)

コメント

  1. zoritoler imol より:

    The next time I read a blog, I hope that it doesnt disappoint me as much as this one. I mean, I know it was my option to read, but I really thought youd have something fascinating to say. All I hear is a bunch of whining about one thing that you would fix in case you werent too busy searching for attention.

タイトルとURLをコピーしました