0
0

More than 1 year has passed since last update.

レスポンシヴウェブデザイン

Posted at

.600px から800pxの間だけ背景をつける

@media (min-width: 600px) and (max-width: 800px) {
  body {
    background: skyblue;
  }
}

🌟モバイルファーストで小さい方から書いていく

・画面幅に合わせて可変を使うとき

aside {
  display: none; ←600px以下では広告を表示しない
}

.image {
  background: pink;
  height: 100px;
}

.text {
  background: silver;
  height: 100px;
}

/* medium screen */
600px以下では横並びにし、textに可変を効かせる

@media (min-width: 600px) {
  section {
    display: flex;
  }

  .image {
    width: 200px;
  }

  .text {
    flex: 1;
  }
}

/* large screen */
@media (min-width: 800px) {
  section {
    width: 800px;
    margin: 0 auto;
  }

  aside {
    display: block; ←noneにしていたため初期値のblockに戻す
    background: plum;
    width: 160px;
  }
}
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