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本ノック】0041_Flexboxコンテナを作成し、flex-directionの4つの値(row, row-reverse, column, column-reverse)を切り替えて挙動を確認せよ。

Posted at

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

はじめに

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

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

Flexbox コンテナと flex-direction

Flexboxコンテナは、親要素に display: flex; を指定することから始まります。これを Flexコンテナと呼び、その中の子要素を Flexアイテムと呼びます。

flex-direction は、アイテムをどの方向に並べるか(主軸)を決定する、最も基本的なプロパティです。

  • row(デフォルト):アイテムを左から右へ、行方向に並べる
  • row-reverse:アイテムを右から左へ、行方向に並べる
  • column:アイテムを上から下へ、列方向に並べる
  • column-reverse:アイテムを下から上へ、列方向に並べる

作成したコード

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本ノック 0041</title>
</head>
<body>
    <main>
      <h1>flex-direction プロパティ</h1>

      <section>
        <h2>flex-direction: row</h2>
        <div style="display: flex; flex-direction: row;">
          <div style="width: 100px; height: 100px; background-color: azure;">1</div>
          <div style="width: 100px; height: 100px; background-color: bisque;">2</div>
          <div style="width: 100px; height: 100px; background-color: burlywood;">3</div>
        </div>
      </section>

      <section>
        <h2>flex-direction: row-reverse</h2>
        <div style="display: flex; flex-direction: row-reverse;">
          <div style="width: 100px; height: 100px; background-color: azure;">1</div>
          <div style="width: 100px; height: 100px; background-color: bisque;">2</div>
          <div style="width: 100px; height: 100px; background-color: burlywood;">3</div>
        </div>
      </section>

      <section>
        <h2>flex-direction: column</h2>
        <div style="display: flex; flex-direction: column;">
          <div style="width: 100px; height: 100px; background-color: azure;">1</div>
          <div style="width: 100px; height: 100px; background-color: bisque;">2</div>
          <div style="width: 100px; height: 100px; background-color: burlywood;">3</div>
        </div>
      </section>

      <section>
        <h2>flex-direction: column-reverse</h2>
        <div style="display: flex; flex-direction: column-reverse;">
          <div style="width: 100px; height: 100px; background-color: azure;">1</div>
          <div style="width: 100px; height: 100px; background-color: bisque;">2</div>
          <div style="width: 100px; height: 100px; background-color: burlywood;">3</div>
        </div>
      </section>
      

    </main>
    <footer>
      <p>Copyright 2025</p>
      <p>フロントエンド1000本ノック</p>
    </footer>

</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?