Hackforge Academy

Category: html_css

css Media queries

Published on 29 Jun 2026

Explanation

Media queries apply different CSS styles based on screen size, orientation, or device characteristics.

Code:

@media (max-width: 768px) {
  body {
    background: lightgray;
  }
}

Explanation

You can change font sizes for smaller screens to improve readability.

Code:

@media (max-width: 600px) {
  h1 {
    font-size: 24px;
  }
}

Explanation

Media queries can change layout direction from horizontal to vertical on mobile devices.

Code:

@media (max-width: 768px) {
  .container {
    flex-direction: column;
  }
}

Explanation

Different styles can be applied for larger screens using the min-width condition.

Code:

@media (min-width: 1024px) {
  .container {
    max-width: 1200px;
  }
}

Explanation

Multiple media queries can be combined to create fully responsive layouts across various devices.

Code:

@media (max-width: 480px) {
  .menu {
    display: none;
  }
}

๐Ÿš€ Learn Spring Boot with real-world projects

๐Ÿ’ก Build REST APIs step by step

๐Ÿง  Improve backend development skills

๐ŸŽฏ Get career-ready practical training

Join Our Free WhatsApp Community

Direct access to niche-specific mentors and peers on WhatsApp.

๐Ÿ

Python Community

Discuss Django, FastAPI, AI integration, and automation scripts with 15k+ developers.

Join Python Community
โš›๏ธ

React Community

Master Next.js, Framer Motion, and State Management. Share your latest UI components.

Join React Community
โ˜•

Java Community

Deep dives into Spring Boot, Microservices architecture, and high-performance backend ops.

Join Java Community