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

はじめに

CSSを学びたい!!Step4です!
今回はauto-fit、minmaxを扱いレスポンシブ対応を実施していきます。

成果物

150px以下にならないようにレスポンシブ対応しています。
この場合、150px以下になる場合は段組みが変わります。
step4.gif

ソースコード

index.html
<!DOCTYPE html>
<html lang="ja">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>CSS Grid Layout with auto-fit and minmax</title>
    <link rel="stylesheet" href="styles.css">
</head>
<body>
    <div class="card-container">
        <div class="card">カード1</div>
        <div class="card">カード2</div>
        <div class="card">カード3</div>
        <div class="card">カード4</div>
        <div class="card">カード5</div>
        <div class="card">カード6</div>
      </div>
</body>
</html>
styles.css
.card-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 16px;
    padding: 16px;
  }
  
  .card {
    background-color: #f4f4f9;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 20px;
    text-align: center;
  }
1
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
1
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?