<!DOCTYPE html>
<html lang="ja">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Aspect Ratio Example</title>

</head>
<body>
    <div class="container">
        <div class="box ar-16-9">16:9</div>
        <div class="box ar-1-1">1:1</div>
        <div class="box ar-3-2">3:2</div>
    </div>
</body>
</html>
.container {
            display: grid;
            gap: 20px;
            grid-template-columns: repeat(3, 100px);

        }
        .box {
            background-color: teal;
            color: white;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 16px;
          
        }
        .ar-16-9 {
            /* 横幅16:縦幅9 */
            aspect-ratio: 16 / 9;
            width: 100px;
          height: auto;
        }
        .ar-1-1 {
            /* 横幅1:縦幅1 */
            aspect-ratio: 1 / 1;
            width: 100px;
          height: auto;
        }
        .ar-3-2 {
            /* 横幅3:縦幅2 */
            aspect-ratio: 3 / 2;
            width: 100px;
          height: auto;
        }

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.