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本ノック】0059_minmax()関数を使い、グリッドトラックの最小幅と最大幅を指定することで、柔軟なレスポンシブグリッドを作成せよ。

Posted at

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

はじめに

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

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

minmax() 関数とは

minmax() 関数は、その名の通り、グリッドの列(トラック)の最小値と最大値を同時に指定できる機能です。

minmax(最小値, 最大値) のように使います。

これにより、「普段は親の半分に合わせて可変でいてほしいけど、どんなに縮んでも最低限この幅は維持してほしい」といった、柔軟なレスポンシブデザインが簡単に実現できます。

例えば、grid-template-columns: 200px minmax(300px, 1fr); は、1列目は 200px で固定し、2列目は、最低でも 300px の幅を確保しつつ、利用可能な残りのスペースを全て使って伸びるという意味になります。

作成したコード

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本ノック 0059</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: 200px minmax(500px, 1fr);">
    <div>サイドバー</div>
    <div>メインコンテンツ</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?