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本ノック】0048_orderプロパティを使い、HTMLの記述順とは異なる順番でフレックスアイテムを表示させよ。

Posted at

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

はじめに

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

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

order プロパティとは

order プロパティは、個々の Flexアイテムに指定することで、コンテナ内での表示順を視覚的に変更できる機能です。HTML の構造を変えることなく、CSS だけで順番を入れ替えることができます。

全てのアイテムはデフォルトで order: 0 を持っています。この数値を変更することで、順番を制御します。

例えば、数値が小さいほど手前(先頭)に、大きいほど奥(末尾)に表示されます。ちなみに、マイナスの値も使えます。

作成したコード

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

      <div style="display: flex;">

        <div style="order: 2;">1</div>
        <div style="order: 3;">2</div>
        <div style="order: -1;">3</div>
        
      </div>

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