5
4

More than 5 years have passed since last update.

borderの幅を変えた時に全体幅ごと変わってしまう問題

Posted at

input要素などに対してフォーカス時にborderの幅を変えたいとき、
通常だとborderの幅は全体の幅に含まれないため、borderの幅が増えた分、
要素自体の幅も大きくなってガタガタしてしまう。

これを解決するプロパティとして、

 box-sizing

というものがある。

 box-sizing: border-box;

というプロパティを追加することで、borderの幅も全体の幅に含めて考慮してくれるので、
上記の問題は解消される。

5
4
0

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
5
4