A collection of CSS Flexbox examples and demonstrations for learning and experimenting with modern CSS layout techniques.
Built in November 2018. This project provides hands-on examples of CSS Flexbox properties and patterns, including responsive navigation menus, nested flex containers, and interactive layout toggles.
- π¦ Basic flexbox ordering and alignment examples
- π± Responsive navigation menu with mobile-first approach
- π Nested flexbox containers with multiple menus
- ποΈ Interactive grid vs stack layout toggle
- π‘ Clean, well-commented code for learning
- π No build process - pure HTML/CSS
- β Cross-browser compatible (modern browsers)
- A modern web browser (Chrome, Firefox, Safari, or Edge)
- No dependencies or build tools required
- Clone the repository:
git clone https://github.com/orassayag/flexbox-plays.git
cd flexbox-plays- Open any HTML file in your browser:
# Open main example
open index.html
# or
open example-1/menu.htmlNo installation, build, or compilation needed - just open and explore!
File: index.html
Demonstrates basic flexbox ordering with numbered blocks that display in a custom order using the order property.
βββββ¬ββββ¬ββββ¬ββββ
β 2 β 1 β 4 β 3 β
βββββ΄ββββ΄ββββ΄ββββ
Key Concepts:
display: flexorderpropertyjustify-content: space-between- Fixed flex basis
File: example-1/menu.html
A responsive navigation menu that stacks vertically on mobile and displays horizontally on desktop.
Mobile:
βββββββββββ
β Home β
βββββββββββ€
β About β
βββββββββββ€
β Store β
βββββββββββ€
β Contact β
βββββββββββ
Desktop (β₯768px):
ββββββββ¬βββββββ¬βββββββ¬ββββββββββ
β Home β Aboutβ Storeβ Contact β
ββββββββ΄βββββββ΄βββββββ΄ββββββββββ
Key Concepts:
- Media queries
- Mobile-first responsive design
- Equal width flex items
- Hover effects
File: example-2/nested-menu.html
Navigation with main menu and social media links using nested flex containers.
ββββββββ¬βββββββ¬βββββββ¬ββββββββββ¬βββββββββββ¬ββββββββββ
β Home β Aboutβ Storeβ Contact β Facebook β Twitter β
ββββββββ΄βββββββ΄βββββββ΄ββββββββββ΄βββββββββββ΄ββββββββββ
Key Concepts:
- Nested flexbox containers
- Multiple flex rows
space-betweenalignment- Responsive social links
File: example-3/grid-vs-stack.html
Interactive example with a toggle button to switch between grid and stacked article layouts.
Grid Layout:
βββββββββββ¬ββββββββββ¬ββββββββββ
βArticle 1βArticle 2βArticle 3β
βββββββββββΌββββββββββΌββββββββββ€
βArticle 4βArticle 5βArticle 6β
βββββββββββ΄ββββββββββ΄ββββββββββ
Stack Layout:
βββββββββββββββββββββββββββββββββ
β Article 1 β
βββββββββββββββββββββββββββββββββ€
β Article 2 β
βββββββββββββββββββββββββββββββββ€
β Article 3 β
βββββββββββββββββββββββββββββββββ
Key Concepts:
flex-wrap: wrap- Dynamic class toggling
- Article grid layout
- jQuery integration
- Flexible article cards
graph TD
A[Flexbox Plays Project] --> B[Main Example]
A --> C[Example 1: Menu]
A --> D[Example 2: Nested Menu]
A --> E[Example 3: Grid vs Stack]
B --> B1[index.html]
B --> B2[style.css]
C --> C1[example-1/menu.html]
C --> C2[example-1/style.css]
D --> D1[example-2/nested-menu.html]
D --> D2[example-2/style.css]
E --> E1[example-3/grid-vs-stack.html]
E --> E2[example-3/style.css]
E --> E3[jQuery Integration]
B1 --> F[Flexbox Concepts]
C1 --> F
D1 --> F
E1 --> F
F --> F1[display: flex]
F --> F2[justify-content]
F --> F3[align-items]
F --> F4[flex-wrap]
F --> F5[order]
F --> F6[flex basis/grow/shrink]
flexbox-plays/
βββ index.html # Basic flexbox ordering
βββ style.css # Main example styles
βββ example-1/ # Responsive menu
β βββ menu.html
β βββ style.css
βββ example-2/ # Nested menu
β βββ nested-menu.html
β βββ style.css
βββ example-3/ # Grid vs Stack
β βββ grid-vs-stack.html
β βββ style.css
βββ README.md # This file
βββ CONTRIBUTING.md # Contribution guidelines
βββ INSTRUCTIONS.md # Detailed usage instructions
βββ LICENSE # MIT license
| Property | Description | Values |
|---|---|---|
display |
Defines flex container | flex, inline-flex |
flex-direction |
Main axis direction | row, column, row-reverse, column-reverse |
justify-content |
Main axis alignment | flex-start, flex-end, center, space-between, space-around |
align-items |
Cross axis alignment | flex-start, flex-end, center, stretch, baseline |
flex-wrap |
Item wrapping | nowrap, wrap, wrap-reverse |
| Property | Description | Values |
|---|---|---|
flex |
Shorthand for grow/shrink/basis | <grow> <shrink> <basis> |
order |
Display order | <integer> |
align-self |
Individual cross axis alignment | auto, flex-start, flex-end, center, baseline, stretch |
- β Chrome (29+)
- β Firefox (28+)
- β Safari (9+)
- β Edge (12+)
β οΈ IE 11 (with prefixes)
Contributions to this project are released to the public under the project's open source license.
Everyone is welcome to contribute. Contributing doesn't just mean submitting pull requestsβthere are many different ways to get involved, including answering questions and reporting issues.
Please see CONTRIBUTING.md for detailed contribution guidelines.
- Or Assayag - Initial work - orassayag
- Or Assayag orassayag@gmail.com
- GitHub: https://github.com/orassayag
- StackOverflow: https://stackoverflow.com/users/4442606/or-assayag?tab=profile
- LinkedIn: https://linkedin.com/in/orassayag
This application has an MIT license - see the LICENSE file for details.