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本ノック】0058_グリッドアイテムの配置プロパティjustify-selfとalign-selfを試し、セル内でのアイテムの位置を制御せよ。

Posted at

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

はじめに

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

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

justify-selfalign-self とは

justify-itemsalign-items がコンテナ側で全てのアイテムの配置を一度に決めるのに対し、justify-selfalign-self は個々のアイテム側で、自分自身のセル内での配置を上書きするためのプロパティです。

  • jystify-self:セル内の水平方向の配置を決める
  • align-self:セル内の垂直方向の配置を決める

指定できる値は、主に以下の4つです。

  • stretch(デフォルト):セル全体を埋めるように引き伸ばされる
  • start:セルの始点に配置する(左揃え / 上揃え)
  • end:セルの終点に配置する(右揃え / した揃え)
  • center:セルの中央に配置する

作成したコード

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本ノック 0058</title>
</head>
<body style="display: flex; flex-direction: column; min-height: 100vh;">

  <header style="display: flex; justify-content: space-between; align-items: center;">
    <div>
      <a href="/">
        <img src="img/logo.png" alt="フロントエンド1000本ノック">
      </a>
    </div>
  </header>

  <div style="display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px;">
    <div style="border: 1px solid #ccc; justify-self: start; align-self: start;">1</div>
    <div style="border: 1px solid #ccc; justify-self: center; align-self: start;">2</div>
    <div style="border: 1px solid #ccc; justify-self: end; align-self: start;">3</div>
    <div style="border: 1px solid #ccc; justify-self: start; align-self: center;">4</div>
    <div style="border: 1px solid #ccc; justify-self: center; align-self: center;">5</div>
    <div style="border: 1px solid #ccc; justify-self: end; align-self: center;">6</div>
    <div style="border: 1px solid #ccc; justify-self: end; align-self: end;">7</div>
    <div style="border: 1px solid #ccc; justify-self: start; align-self: end;">8</div>
    <div style="border: 1px solid #ccc; justify-self: center; align-self: end;">9</div>
  </div>

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