Some examples to practice with and learn about making layouts with CSS. These examples cover:
- Basic layouts using the box model.
- Flexbox
- CSS Grid
NOTE: Make sure you have the latest version (LTS) of Node installed before beginning.
If you're not sure if you have Node installed, run the command node -v
in
Terminal/Command Prompt and it should return the version of Node you have
installed.
- In Terminal/Command Prompt, go to the project root directory:
css-layout-examples
. - Run
npm install
(shorthand:npm i
) to install dependencies.
-
- In Terminal/Command Prompt, go to the project root directory:
css-layout-examples
.
- In Terminal/Command Prompt, go to the project root directory:
- Run
npm start
to start the dev server. - Go to
localhost:7777
in any web browser to explore the examples.
NOTE: Some examples make use of newer features in CSS. It is important that
you've updated your browser recently in order to ensure all examples work as
expected. These examples were created using Google Chrome Version 65.0.3325.181
and Firefox Quantum 59.0.2
.
Here are some resources I've used to learn about web layouts:
- CSS Box Model [Tutorial]
Probably just Google how to do stuff... Everything you find about float layouts is inherently going to be hacky (unless you're flowing content around text). :P
- CSS Grid Course - Wes Bos [Course]
- Layout Land - Jen Simmons, Mozilla Designer and Developer Advocate [YouTube]
- Learn CSS Grid - Jen Simmons [Article]
- CSS Grid Layout Module [Tutorial]
The dev environment setup and some styles for these examples was taken from Wes Bos's CSS Grid course and some examples were inspired by it. I strongly encourage you to check out the course. It's free, and has great examples with video tutorials.