Skip to content
View in the app

A better way to browse. Learn more.

OKCCN - XenForo & IPS Plugin Marketplace

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.
  • Language

CSS Responsive Flexbox

Featured Replies

  • Administrators

CSS Responsive Flexbox


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):

1
2
3

Resize the browser window to see the effect.

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;
  }
}

Try it Yourself »

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%;
  }
}

Try it Yourself »



Responsive Image Gallery using Flexbox

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

Try it Yourself »

Responsive Website using Flexbox

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

Try it Yourself »


Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.