Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / CSS

Responsive design

Responsive design adapts a layout to the available space instead of assuming one fixed page size. CSS supports this through flexible layouts and conditional rules, such as @media queries based on viewport width.

Version: CSS modules; structured CSSWG indexes reconciled with pinned MDN BCD; Chromium 152 scope gate, per-example verification still required

Syntax

.cards { display: grid; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 600px) {
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

Responsive design (responsive design) is an approach to building interfaces, not a CSS property or keyword. The layout adapts to available space: elements can change size and arrangement.

A flexible layout can respond to width changes without switching rules. An @media query adds a conditional change at a particular breakpoint. The condition (min-width: 600px) includes exactly 600px; it tests the viewport width, not the physical device width. The px unit here means CSS pixels.

In the example, .cards initially has one column. From 600px upward, the rule appearing later in the stylesheet sets two equal columns. minmax(0, 1fr) lets a column shrink below its content-based minimum, while overflow-wrap: anywhere allows long text to wrap. Flexible column sizing alone does not guarantee that arbitrary content will never overflow.

Examples

<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>Responsive grid</title>
  <style>
    body { margin: 0; }
    .cards {
      display: grid;
      grid-template-columns: minmax(0, 1fr);
      gap: 16px;
    }
    .cards > div {
      padding: 16px;
      background: #e8eef8;
      overflow-wrap: anywhere;
    }
    @media (min-width: 600px) {
      .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    }
  </style>
</head>
<body>
  <main class="cards">
    <div>A</div>
    <div>B</div>
  </main>
</body>
</html>

Result

Viewport width 599 CSS px: A above B, one column.
Viewport width 600 CSS px: A beside B, two equal columns with a 16px gap.

The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.

Sources