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?

【フロントエンド1000本ノック】0067_メディアクエリを使い、画面幅が768px以上の場合に2カラム、それ未満の場合に1カラムになるレイアウトを作成せよ。

Posted at

この記事は人間が書きました

はじめに

こんにちは、赤神です!
この記事は、「1000本ノック」という取り組みの中のフロントエンドのための課題の1つです。

「1000本ノックとは」
https://qiita.com/sora_akagami/items/c8da4296dea3823376ca

メディアクエリ

メディアクエリは、@media から始まる特別なCSSの構文で、「もし〜という条件を満たしたら、このCSSを適用する」というルールを書くことができます。

最もよく使うのが、画面の幅(min-widthmax-width)を条件にする方法です。

/* 画面幅が768px以上の場合に適用 */
@media (min-width: 768px) {
  .container {
    /* PC・タブレット用のスタイル */
    display: flex;
  }
}

この 768px のような、スタイルが切り替わる幅のことをブレイクポイントと呼びます。

作成したコード

index.html
<!DOCTYPE html>
<html lang="ja">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>フロントエンド1000本ノック 0067</title>
  <style>
    @media (min-width: 768px) {
      .container {
        display: grid;
        grid-template-columns: 1fr 250px;
      }
    }
  </style>
</head>
<body>
  <div class="container">
    <main>メインコンテンツ</main>
    <aside>サイドバー</aside>
  </div>
</body>
</html>
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?