Edward Apostol, February 08th , 2024
This repository contains a collection of demos for the Flexbox layout model.
The demos are designed to be used as a reference for developers who are learning about Flexbox for the first time, or for those who want to refresh their knowledge.
To use this repo, you will have to
- first
git clone
the repository in your git bash shell or mac terminal, and - Use the command
git checkout <name-of-branch>
to see the different examples, where<name-of-branch>
corresponds to a branch in this repo.
For example, if you wanted to see the code for branch 08-flexibility-grow-shrink-basis, which demonstrates how a flex-grow
can be used expand the size of a child container relative to its siblings, you would perform the command
git checkout 08-flexibility-grow-shrink-basis
once you had cloned the repository to your local computer.
After switching to that branch, you can open the index.html
file in your browser to see the demo in action.
The demos are designed to be viewed in the order of the branch numbers, as the concepts build on each other. However, you can also jump to a specific branch to see a particular concept in action.
The following is a list of the branches in this repository:
- 01-toggle-flex-container
- 02-switch-flex-direction
- 03-toggle-flex-wrap
- 04-switch-flex-justify-content
- 04-switch-flex-justify-content-single
- 04-switch-flex-justify-cross-axis
- 05-switch-flex-align-items-cross-axis
- 06-switch-flex-space-lines-align-content
- 07-switch-flex-complex-item-order
- 07-switch-flex-item-order
- 08-flexibility-grow-shrink-basis
- 09-flexibility-flex-grow
Note the main files to explore are the changes made to the index.html
and main.css
files in each branch. The javascript file adds additional interactivity to the demos, and are not relevant to learning about Flexbox.
The key concepts covered in this repository include:
- Flex containers and items
- The
flex-direction
property - The
flex-wrap
property - The
justify-content
property - The
align-items
property - The
align-content
property - The
order
property - The
flex-grow
property - The
flex-shrink
property - The
flex-basis
property - The
flex
shorthand property - The
align-self
property - The
flex
property
The .css file will have a container class, called flexcontainer which will set whatever HTML element it is applied to as a flex container. The .css file will also have a class called flexitem which will set whatever HTML element it is applied to as a flex item.