We may earn an affiliate commission when you visit our partners.
Course image
Peter Sommerhoff
  • vertically align any element

  • create modern grids

  • take up remaining space

  • add spacing between elements

  • implement complete site layouts

  • and much more.

More goodies inside this course:

Read more
  • vertically align any element

  • create modern grids

  • take up remaining space

  • add spacing between elements

  • implement complete site layouts

  • and much more.

More goodies inside this course:

  • I'll answer all questions you may have along the way to make sure you reach your learning goals

  • I've added manual, high-quality captions (CC) to this course

  • To see Flexbox in practice, 3 mini-projects will manifest your skills and enable you to use Flexbox productively in future web design projects.

What Students Say About Me (taken from various courses of mine)

Such a great course. second one for me with Peter Sommerhoff.a great Instructor, uses very easy way to explain the materials.

- Ahmed

I absolutely LOVE this course, it teaches everything you need in details and more. They really do listen to their students and answer as fast as the road runner. Thanks so much for posting your course and I am looking forward other courses.

- Ana

Great course, Peter explained it thoroughly, and he answers any questions within a day.

- Dunja

The course covered the required information quickly and concisely without fluff or wasted motion. It provides sufficient pointers to additional information and documentation. I thought it was a good value.

- Robert

I'm glad to have received such great reviews from my students and I'll do my best to provide you with the best learning I can as well.

Check out the free preview videos below.

I look forward to seeing you inside :)

In this tutorial, you'll learn to use each and every Flexbox property:

Styling flex containers:

  1. flex-direction

  2. justify-content

  3. align-items

  4. flex-wrap

  5. align-content

Then individual flex items:

  1. order

  2. align-self

  3. flex-grow

  4. flex-shrink

  5. flex-basis

  6. flex

At the end, we'll look at real-world Flexbox examples to see what kinds of layouts can be achieved:

  1. Simple grids with Flexbox where all columns in a row have the same size

  2. More advanced Flexbox grids where columns can have arbitrary sizes

  3. Vertical centering to vertically align any element

  4. Media objects, the popular OOCSS pattern

  5. The Holy Grail Layout, a complete site layout with sidebars and sticky footer

As a bonus, this course includes a complete Flexbox Cheat Sheet that you can use to recap all you've learned and to refer back to while using Flexbox.

Additionally, I included the code for a Flexbox demo showcase  which is like an interactive cheat sheet for you to see in the browser that contains every property and every layout example from this tutorial.

Enroll now

What's inside

Learning objectives

  • Use css flexbox confidently to create modern layouts
  • Create web site designs more effectively
  • Write high-quality and reusable css code
  • Vertically align any element
  • Take up the remaining space in a container
  • Beautiful responsive galleries with flexbox
  • Implement the so-called holy grail layout

Syllabus

Learn how to best follow along this course

Thanks so much for joining this course!

Now, let's make sure you get the most out of this course :)

Read more

Learn about what Flexbox is and what you can do with this new CSS box model to make your job easier and work more productively.

Flexbox is supported by 97.5% of users worldwide (Feb 2017, caniuse.com) with prefixing. Only IE 10 and below, and old Android browsers are not supported.

Thus, you can now finally start using Flexbox for most audiences to use very concise and beautiful solutions for tasks that have been unnecessarily complicated before.

Prefixing can be done using intelligent code editors, online tools, or build tools.

There is no setup required to use Flexbox, it's part of the CSS 3 standard and not a framework or library. Of course you should have a code editor that knows Flexbox and can offer autocomplete etc., such as Sublime Text, Atom or an IDE.

Flexbox uses the concepts of main axis and cross axis. If the flex container is defined as a row, the main axis will be horizontal and the cross axis thus vertical. If the container is a column layout (defined via flex-direction later), it's the other way around.

The cross axis is always perpendicular to the main axis.

It's important to understand this concept to know what the effect the Flexbox properties will have later on in this course.

This is your chance to test your knowledge of this section!

In Flexbox, you can define the flex container to have a row or column layout using either flex-direction: row or flex-direction: column.

Also, if you want the flex container to be filled from the end of the main axis (e.g. from the right in a row), you can add reverse to the values: flex-direction: row-reverse or flex-direction: column-reverse.

Valid values are:

  • flex-direction: row; (default)
  • flex-direction: column;
  • flex-direction: row-reverse;
  • flex-direction: column-reverse;

Let's see if you can recall the most important info about flex-direction.

With justify-content, you can specify how flex items will align along the main axis and what spacing they'll have.

Valid values are:

  • justify-content: flex-start;
  • justify-content: flex-end;
  • justify-content: center;
  • justify-content: space-around;
  • justify-content: space-between;

Try recalling what's essential about justify-content.

With align-items, flex items can be aligned along the cross axis. For example, align them at the top or bottom (of a row).

Valid values are:

  • align-items: stretch;
  • align-items: flex-start;
  • align-items: flex-end;
  • align-items: center;
  • align-items: baseline;

Test your knowledge of the align-items property!

To create multiple rows or columns, you can enable flex-wrap by using either wrap or wrap-reverse as the default, in contrast to the default value nowrap.

This way, flex items will flow into the next or column once it would overflow. With flex-wrap: nowrap, it may well happen that your flex container will overflow.

Valid values are:

  • flex-wrap: nowrap; (default)
  • flex-wrap: wrap;
  • flex-wrap: wrap-reverse;

Test what you just learned about flex-wrap!

Once you have multiple rows or columns, you will probably want to control the alignment and spacing of these rows/columns. This is exactly what align-content is for, which is essentially the same as justify-content but for the cross axis. Thus, align-content only makes sense once you have more than one row or column.

Valid values are (same as justify-content):

  • align-content: flex-start;
  • align-content: flex-end;
  • align-content: center;
  • align-content: space-around;
  • align-content: space-between;

Check your knowledge about align-content!

With order, you can change the order of your flex items independent of their actual order in the HTML markup. This allows for more dynamic layouts without relying heavily on JavaScript.

The default value for order is 0, thus you have to use a negative number to move an item to the front.

Valid values are:

  • All positive numbers, negative numbers, and zero.

In Flexbox, align-self allows you to override whatever basic layout you set via justify-content. Normally, you would of course do this only for specific flex items which should not follow the parent layout.

Valid values are:

  • same as justify-content

By default, flex items will not take up remaining space in their parent. With Flexbox, you can simply set flex-grow to 1 or above to allow a flex-item to fill remaining space.

If multiple flex items have flex-grow set to >0, the remaining space will be split up between them depending on their flex-grow number - the higher the number is, the more they will expand. For details about the calculation, check the video.

Valid values are:

  • 0 (default)
  • positive numbers

Check your knowledge on the flex-grow property, this one is essential!

If the flex container cannot contain all its items with their specified size, the flex items will by default be allowed to shrink in order to fit. However, Flexbox will only shrink items to some degree (depending on their content and padding) so the flex container may still overflow.

You can disable shrinking for flex items by setting flex-shrink to 0. Similarly, larger values for flex-shrink will make it shrink more compared to other items.

Valid values are:

  • 1 (default)
  • 0 (forbid shrinking)
  • all positive numbers

Test what you learned about flex-shrink in this quiz!

In Flexbox, flex items will only adhere to width and height properties if there is no value for flex-basis specified. However, the best practice is to use flex-basis which will refer to width in row containers and to height in column containers.

When calculating the size of each flex item, the flex-basis value will be evaluated first. Only after that, flex-grow and flex-shrink will be used to divide up remaining (or overflowing) space.

Valid values are:

  • Any px, em, rem, % values (like you would to for width/height)

Congrats for making it here.

Check what you learned about flex-basis, the last property of the Flexbox box model.

This first solution for Flexbox grids uses minimal markup and CSS code but is already powerful enough for a majority of use cases.

Each grid row will be in its own container, with all elements spanning the same size inside the container via flex: 1. You can use this for teasers showing advantages of your product, review blocks or any other simple multi-column module.

In this solution, you'll create more flexible grids with Flexbox which use flex-wrap to create galleries with multiple rows in one flex container. Also, via classes with different flex-basis values, you'll be able to define how much space each flex item should take up.

This solution is for more advanced galleries where the items in one row should not necessarily be of the same size.

Ever tried vertical-align: middle to no avail? Well, it only works for inline elements and table cells. Finally, with Flexbox you can center any element with just one or two lines of code. This is one of the things that should have been possible in CSS right from the beginning.

Using a flex container and align-items: center, you're now able to vertically center any element inside a flex container. This tutorial shows you two different use cases for this.

A media object is a module with a picture and some content, possibly nested. Think comment sections on a blog. It's a highly useful and reusable module made popular by the OOCSS approach (object-oriented CSS).

Here, you'll learn to easily create flexible media objects using Flexbox which are highly maintainable and fulfill more requirements than described above. In the video, we'll discuss all we want the media object to be able to do.

The Holy Grail Layout is essentially a 3-column layout with a header and a sticky footer where all columns should have equal height at all times, the footer should be sticky, and the HTML markup for the content should come before the markup for both sidebars.

Implementing this layout with CSS was only possible with some kind of compromise before. With Flexbox, you're finally able to use a Holy Grail Layout. In this lecture, I'll show you how.

All properties of Flexbox in one PDF overview.

This is essentially a PDF version of the showcase, so you can always look at this interactively and even modify it using the showcase code.

All you've learned in this course!

Let me know if you have any suggestions for another example of Flexbox in practice :)

Check out other web design & development courses of mine for $10.

Save this course

Create your own learning path. Save this course to your list so you can find it easily later.
Save

Activities

Coming soon We're preparing activities for Complete Flexbox Course: Master CSS3 Flexbox for Good. These are activities you can do either before, during, or after a course.

Career center

Learners who complete Complete Flexbox Course: Master CSS3 Flexbox for Good will develop knowledge and skills that may be useful to these careers:

Reading list

We haven't picked any books for this reading list yet.
A classic introduction to CSS, including a chapter on Flexbox.
Provides a thorough exploration of CSS, going beyond the basics to cover complex topics like Flexbox and Grid in detail. It's particularly useful for solidifying understanding through practical examples and explanations of how CSS truly works. While not solely focused on Flexbox, its in-depth coverage makes it a valuable resource for those looking to deepen their knowledge and understand contemporary CSS layout techniques.
Considered a classic in the CSS world, this comprehensive guide covers all aspects of CSS, including detailed explanations of layout models like Flexbox. The latest editions are updated to include modern CSS features. is an excellent reference tool and is often used in academic settings to provide a foundational and deep understanding of CSS. Its authority comes from its long-standing reputation and expert authors.
This is the foundational book that introduced the concept of responsive web design, which primary use case for Flexbox. While it predates widespread Flexbox adoption, it provides essential context for why flexible layout techniques are necessary. Reading this book helps solidify the 'why' behind using tools like Flexbox for creating websites that adapt to various devices. It's a classic and a must-read for understanding the evolution of web layout.
This visually rich book is excellent for beginners to gain a broad understanding of both HTML and CSS, including an introduction to layout concepts that precede Flexbox. It's widely popular for its clear explanations and engaging design, making it a good starting point before diving deep into Flexbox. It provides necessary background knowledge for anyone new to web development.
A well-regarded book for beginners that covers the fundamentals of web design, including CSS layout. While it may not focus exclusively on Flexbox, it provides a solid foundation in CSS that is essential before tackling more advanced layout techniques. is often recommended as a textbook for introductory web design courses.
This concise reference book is invaluable for quickly looking up CSS properties, including those for Flexbox. While not a tutorial, it's an essential tool for anyone working regularly with CSS. It's best used as a reference alongside more comprehensive learning resources.
Specifically targets Flexbox, offering a dedicated and in-depth look at its properties and usage. It's a valuable resource for those who want to focus on mastering Flexbox specifically. It helps solidify understanding through detailed explanations and examples.
Takes a practical approach to building responsive websites using modern HTML5 and CSS, including Flexbox. It's good for seeing how Flexbox fits into a broader responsive design workflow. It provides hands-on examples and is suitable for those who learn best by doing.
This comprehensive book covers the three core technologies of web development, including CSS with modern techniques like Flexbox. It's a good resource for gaining a broad understanding of the web development landscape and how Flexbox integrates with HTML and JavaScript. It can serve as both a learning resource and a reference.
Delves into advanced CSS techniques and explores the future of CSS. While it might not be solely focused on Flexbox, it provides valuable context for understanding how Flexbox fits into the broader landscape of advanced CSS and modern web design. It's suitable for those who have a solid grasp of CSS fundamentals.
Focuses on progressive enhancement, a philosophy that aligns well with responsive design and the use of Flexbox. While not a Flexbox tutorial, it provides a crucial understanding of building resilient websites that work across different devices and browsers, highlighting the importance of flexible layouts.
Covers HTML5 and CSS3, providing a good overview of the technologies that underpin Flexbox. It's a solid resource for beginners to get a broad understanding of modern web development before focusing on specific layout techniques. It helps establish prerequisite knowledge.
This interactive book is great for beginners learning HTML and CSS, including basic layout concepts. While it might not go into the deepest specifics of Flexbox, its hands-on approach makes learning engaging and helps build a foundational understanding of how to style and structure web pages.
Provides a comprehensive introduction to CSS for beginners, covering fundamental concepts that are necessary before learning Flexbox. While an older publication, its focus on web standards and accessibility remains relevant for building a strong CSS foundation.
While focused on CSS Grid, this project-based book is highly relevant as Flexbox and Grid are often used together for complex layouts. Understanding Grid alongside Flexbox provides a more complete picture of modern CSS layout techniques. is valuable for seeing practical applications of grid, which complements Flexbox knowledge.
By a renowned CSS expert focuses specifically on CSS Grid. As Flexbox and Grid are the two primary modern layout methods, understanding Grid is crucial for choosing the right tool for the job and creating sophisticated layouts by combining them. This book provides in-depth knowledge of Grid.
Focuses on modern CSS layout techniques, including both Flexbox and CSS Grid. Written by a member of the CSS Working Group, it provides authoritative insights into how these layout methods work and how to use them effectively, often together. It's highly relevant for understanding contemporary web layout practices.

Share

Help others find this course page by sharing it with your friends and followers:

Similar courses

Similar courses are unavailable at this time. Please try again later.
Our mission

OpenCourser helps millions of learners each year. People visit us to learn workspace skills, ace their exams, and nurture their curiosity.

Our extensive catalog contains over 50,000 courses and twice as many books. Browse by search, by topic, or even by career interests. We'll match you to the right resources quickly.

Find this site helpful? Tell a friend about us.

Affiliate disclosure

We're supported by our community of learners. When you purchase or subscribe to courses and programs or purchase books, we may earn a commission from our partners.

Your purchases help us maintain our catalog and keep our servers humming without ads.

Thank you for supporting OpenCourser.

© 2016 - 2025 OpenCourser