<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <link rel="stylesheet" href="styles.css">
  <title>Responsive Design Example</title>
</head>
<body>

  <header>
    <h1>Responsive Design Example</h1>
  </header>

  <main>
    <div class="box">Box 1</div>
    <div class="box">Box 2</div>
    <div class="box">Box 3</div>
  </main>

  <footer>
    <p>&copy; 2024 Your Website</p>
  </footer>

</body>
</html>
body {
  font-family: Arial, sans-serif;
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

header {
  background-color: #3498db;
  color: #fff;
  text-align: center;
  padding: 20px;
}

main {
  padding: 20px;
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
}

.box {
  background-color: #8e44ad;
  color: #fff;
  padding: 20px;
  margin: 10px;
  width: calc(33.33% - 20px);
  box-sizing: border-box;
}

/* Responsive Design - Media Queries */
@media only screen and (max-width: 600px) {
  .box {
    width: calc(100% - 20px);
    margin: 10px 0; /* Adjust margin for better spacing */
  }
}

@media only screen and (max-width: 400px) {
  .box {
    width: calc(100% - 20px);
    margin: 10px 0; /* Adjust margin for better spacing */
  }
}

footer {
  background-color: #2ecc71;
  color: #fff;
  text-align: center;
  padding: 10px;
}
Run Pen

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.