From the course: CSS Layouts: From Float to Flexbox and Grid
Unlock the full course today
Join today to access over 24,900 courses taught by industry experts.
Sizing multiple flex items - CSS Tutorial
From the course: CSS Layouts: From Float to Flexbox and Grid
Sizing multiple flex items
- [Instructor] In the last lesson, we talked about sizing flex items using the flex property. But we applied the same flex values to all of the items within the container. But sometimes you may want to have flex items that are not all the same size. The numerical value used for flex-grow represents a ratio. If you want all items to grow by the same amount, then set the flex-grow to 1. But if you want the items to be different sizes, then define different flex-grow values for the individual flex-items. For example, if one item is set to a flex-grow value of 1, and another is set to a flex-grow value of 2, that doesn't mean that one will be twice as big as the other. Flex looks at the flex-basis value first and applies it if there is space. Any extra space is what gets divided among the flex-grow distribution. So the item with the flex-grow value of 1 will get one third of the extra space, and the other will get two…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
- Getting started with Flexbox2m 41s
- (Locked) Orientation with flex-direction and flex-wrap2m 37s
- (Locked) Flexible sizing5m 18s
- (Locked) Sizing multiple flex items1m 18s
- (Locked) The order property54s
- (Locked) Nesting flex containers3m 40s
- (Locked) Exercise: Build a layout with Flexbox, part 16m 29s
- (Locked) Exercise: Build a layout with Flexbox, part 23m 16s
-
-
-