CSS Layout cookbook
The CSS layout cookbook aims to bring together recipes for common layout patterns, things you might need to implement in your own sites. In addition to providing code you can use as a starting point in your projects, these recipes highlight the different ways layout specifications can be used, and the choices you can make as a developer.
Note: If you are new to CSS layout then you might first like to take a look at our CSS layout learning module, as this will give you the basic grounding you need to make use of the recipes here.
|Media objects||A two-column box with an image on one side and descriptive text on the other, e.g. a facebook post or tweet.||CSS Grid,
|Columns||When to choose multi-column layout, flexbox or grid for your columns.||CSS Grid, Multicol, Flexbox|
|Center an element||How to center an item horizontally and vertically.||Flexbox, Box Alignment|
|Sticky footers||Creating a footer which sits at the bottom of the container or viewport when the content is shorter.||CSS Grid, Flexbox|
|Split navigation||A navigation pattern where some links are visually separated from the others.||Flexbox,
|Breadcrumb navigation||Creating a list of links to allow the visitor to navigate back up through the page hierarchy.||Flexbox|
|List group with badges||A list of items with a badge to display a count.||Flexbox, Box Alignment|
|Pagination||Links to pages of content (such as search results).||Flexbox, Box Alignment|
|Card||A card component, which displays in a grid of cards.||Grid Layout|
|Grid wrapper||For aligning grid content within a central wrapper, while also allowing items to break out.||CSS Grid|
As with all of MDN we would love you to contribute a recipe in the same format as the ones shown above. See this page for a template and guidelines for writing your own example.