0
0

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 1 year has passed since last update.

新しいメディアクエリの指定方法

Posted at

今までのメディアクエリの記述の仕方は min-widthmax-widthで定義していましたが、比較演算子=><が使用できるようになりました。

@media (min-width: 400px) {
/* スタイル */
}

このような書き方から

@media (width >= 400px) {
/* スタイル */
}

このようになりました。
他にも、タブレットサイズのみ指定したい場合、

@media (min-width: 768px) and (max-width: 1023px) {
  /* スタイル */
}

このような書き方から

@media (768px <= width <= 1023px )  {
  /* スタイル */
}

このような書き方に変わります。スッキリ書けて、可読性も上がるし、いいことだらけですね。
さらに、不等号だけの書き方にも対応したみたい。
下のコードは上のコードの条件と同じです。この書き方は、ちょっと分かりにくい?

@media (767px < width < 1024px )  {
  /* スタイル */
}

プログラムチックな書き方になり、CSSがさらに書きやすくなります。
でも僕は、SASSで書いているのであんまり関係ないかな。

参考

0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?