🔥Limited Offer: Get 50% OFFon AI & Full Stack Courses🔥
Back to CSS Notes
Topic #176

Flex Responsive


Responsive Flexbox

You learned from the CSS Media Queries chapter that you can use media queries to create different layouts for different screen sizes and devices.

For example, if you want to create a three-column layout for large screen sizes, and a one-column layout for small screen sizes (such as phones), you can change the flex-direction from row to column at a specific breakpoint (600px in the example below):

Example

  .flex-container {
  display: flex;
  flex-direction: row;
}

  .flex-item {
  background-color: #f1f1f1;
  padding: 10px;

  font-size: 30px;
  text-align: center;
  width: 100%;
}

/*
  Make a one column-layout instead of three-column layout */
@media
  (max-width: 600px) {
  .flex-container {

  flex-direction: column;
  }
}

Another way is to change the percentage of the flex property of the flex items to create different layouts for different screen sizes. Note that we also have to include flex-wrap: wrap; on the flex container for this example to work:

Example

  .flex-container {
  display: flex;
  flex-wrap: wrap;
}

.flex-item
  {
  background-color: #f1f1f1;
  padding: 10px;

  text-align: center;
  font-size: 30px;
  flex: 33.3%;
}

/*
  Make a one
  column-layout instead of a three-column layout */
@media (max-width: 600px)
  {
  .flex-item {
    flex: 100%;
  }
}

Here, we use media queries together with flexbox to create a responsive image gallery:


Responsive Website using Flexbox

Use flexbox to create a responsive website, containing a flexible navigation bar and flexible content:

Want to go beyond the notes?

Join CodingNow 2.0's CSS course — live mentorship, real projects, and 100% placement support.

Enroll Now — Free Demo Available

Flex Responsive – FAQs

Quick answers about learning Flex Responsive in CSS.

This free note from CodingNow 2.0 explains Flex Responsive in CSS — concept, syntax and worked code examples you can copy, run and revise before interviews.
Yes. Every CSS topic on CodingNow 2.0, including Flex Responsive, is 100% free with no signup required.
With focused practice, most students grasp Flex Responsive in 1–3 days from these notes; pairing it with CodingNow 2.0's mentor-led course takes you to job-ready depth faster.
Use the code examples in this note, then ask doubts for free on the CodingNow 2.0 Community (/community) — expert instructors answer within 24 hours.
WhatsApp
Call NowEnroll Now