Center vertically with CSS Flexbox

A demo page showing how to align vertically elements using flexbox.
This is the CSS playground of my 'Flexbox vertical centering' article. Please report any bug (or magic trick I missed) in the comment section.

Read first:

Summary:

Text centering

Lorem ipsum dolor sit amet.
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce lobortis ullamcorper mauris ac ullamcorper. Nulla id tristique arcu. Maecenas volutpat dapibus mattis. In fringilla urna sit amet feugiat vehicula. Cras nec lectus ex. Fusce vehicula vulputate rutrum. Mauris congue ex elit, eu tempor tortor eleifend ac.
Lorem ipsum dolor sit amet.
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce lobortis ullamcorper mauris ac ullamcorper. Nulla id tristique arcu. Maecenas volutpat dapibus mattis. In fringilla urna sit amet feugiat vehicula. Cras nec lectus ex. Fusce vehicula vulputate rutrum. Mauris congue ex elit, eu tempor tortor eleifend ac.

Image centering

Single block centering

Solution 1

Lorem ipsum dolor sit amet.
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce lobortis ullamcorper mauris ac ullamcorper. Nulla id tristique arcu. Maecenas volutpat dapibus mattis. In fringilla urna sit amet feugiat vehicula. Cras nec lectus ex. Fusce vehicula vulputate rutrum. Mauris congue ex elit, eu tempor tortor eleifend ac.
Align top modifier. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce lobortis ullamcorper mauris ac ullamcorper. Nulla id tristique arcu. Maecenas volutpat dapibus mattis. In fringilla urna sit amet feugiat vehicula. Cras nec lectus ex. Fusce vehicula vulputate rutrum. Mauris congue ex elit, eu tempor tortor eleifend ac.
Lorem ipsum dolor sit amet.
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce lobortis ullamcorper mauris ac ullamcorper. Nulla id tristique arcu. Maecenas volutpat dapibus mattis. In fringilla urna sit amet feugiat vehicula. Cras nec lectus ex. Fusce vehicula vulputate rutrum. Mauris congue ex elit, eu tempor tortor eleifend ac.

Solution 2: Long content aligned to top on fixed container

Lorem ipsum dolor sit amet.
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce lobortis ullamcorper mauris ac ullamcorper. Nulla id tristique arcu. Maecenas volutpat dapibus mattis. In fringilla urna sit amet feugiat vehicula. Cras nec lectus ex. Fusce vehicula vulputate rutrum. Mauris congue ex elit, eu tempor tortor eleifend ac.
Lorem ipsum dolor sit amet.
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce lobortis ullamcorper mauris ac ullamcorper. Nulla id tristique arcu. Maecenas volutpat dapibus mattis. In fringilla urna sit amet feugiat vehicula. Cras nec lectus ex. Fusce vehicula vulputate rutrum. Mauris congue ex elit, eu tempor tortor eleifend ac.

Single block centering + block 100% height

Solution 1: Long content vertically centered on fixed container

Lorem ipsum dolor sit amet.
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce lobortis ullamcorper mauris ac ullamcorper. Nulla id tristique arcu. Maecenas volutpat dapibus mattis. In fringilla urna sit amet feugiat vehicula. Cras nec lectus ex. Fusce vehicula vulputate rutrum. Mauris congue ex elit, eu tempor tortor eleifend ac.
Lorem ipsum dolor sit amet.
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce lobortis ullamcorper mauris ac ullamcorper. Nulla id tristique arcu. Maecenas volutpat dapibus mattis. In fringilla urna sit amet feugiat vehicula. Cras nec lectus ex. Fusce vehicula vulputate rutrum. Mauris congue ex elit, eu tempor tortor eleifend ac.

Solution 2: Long content aligned to top on fixed container

Lorem ipsum dolor sit amet.
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce lobortis ullamcorper mauris ac ullamcorper. Nulla id tristique arcu. Maecenas volutpat dapibus mattis. In fringilla urna sit amet feugiat vehicula. Cras nec lectus ex. Fusce vehicula vulputate rutrum. Mauris congue ex elit, eu tempor tortor eleifend ac.
Lorem ipsum dolor sit amet.
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce lobortis ullamcorper mauris ac ullamcorper. Nulla id tristique arcu. Maecenas volutpat dapibus mattis. In fringilla urna sit amet feugiat vehicula. Cras nec lectus ex. Fusce vehicula vulputate rutrum. Mauris congue ex elit, eu tempor tortor eleifend ac.

List items centering

Solution 1

Lorem ipsum dolor sit amet.
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce lobortis ullamcorper mauris ac ullamcorper. Nulla id tristique arcu. Maecenas volutpat dapibus mattis. In fringilla urna sit amet feugiat vehicula. Cras nec lectus ex. Fusce vehicula vulputate rutrum. Mauris congue ex elit, eu tempor tortor eleifend ac.
Lorem ipsum dolor sit amet.
Align top modifier. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce lobortis ullamcorper mauris ac ullamcorper. Nulla id tristique arcu. Maecenas volutpat dapibus mattis. In fringilla urna sit amet feugiat vehicula. Cras nec lectus ex. Fusce vehicula vulputate rutrum. Mauris congue ex elit, eu tempor tortor eleifend ac.
Lorem ipsum dolor sit amet.
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce lobortis ullamcorper mauris ac ullamcorper. Nulla id tristique arcu. Maecenas volutpat dapibus mattis. In fringilla urna sit amet feugiat vehicula. Cras nec lectus ex. Fusce vehicula vulputate rutrum. Mauris congue ex elit, eu tempor tortor eleifend ac.

Solution 2: Long content aligned to top on fixed container

Lorem ipsum dolor sit amet.
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce lobortis ullamcorper mauris ac ullamcorper. Nulla id tristique arcu. Maecenas volutpat dapibus mattis. In fringilla urna sit amet feugiat vehicula. Cras nec lectus ex. Fusce vehicula vulputate rutrum. Mauris congue ex elit, eu tempor tortor eleifend ac.
Lorem ipsum dolor sit amet.
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce lobortis ullamcorper mauris ac ullamcorper. Nulla id tristique arcu. Maecenas volutpat dapibus mattis. In fringilla urna sit amet feugiat vehicula. Cras nec lectus ex. Fusce vehicula vulputate rutrum. Mauris congue ex elit, eu tempor tortor eleifend ac.

List items centering + items 100% height

Solution 1

Lorem ipsum dolor sit amet.
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce lobortis ullamcorper mauris ac ullamcorper. Nulla id tristique arcu. Maecenas volutpat dapibus mattis. In fringilla urna sit amet feugiat vehicula. Cras nec lectus ex. Fusce vehicula vulputate rutrum. Mauris congue ex elit, eu tempor tortor eleifend ac.
Lorem ipsum dolor sit amet.
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce lobortis ullamcorper mauris ac ullamcorper. Nulla id tristique arcu. Maecenas volutpat dapibus mattis. In fringilla urna sit amet feugiat vehicula. Cras nec lectus ex. Fusce vehicula vulputate rutrum. Mauris congue ex elit, eu tempor tortor eleifend ac.

Solution 2

Lorem ipsum dolor sit amet.
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce lobortis ullamcorper mauris ac ullamcorper. Nulla id tristique arcu. Maecenas volutpat dapibus mattis. In fringilla urna sit amet feugiat vehicula. Cras nec lectus ex. Fusce vehicula vulputate rutrum. Mauris congue ex elit, eu tempor tortor eleifend ac.
Lorem ipsum dolor sit amet.
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce lobortis ullamcorper mauris ac ullamcorper. Nulla id tristique arcu. Maecenas volutpat dapibus mattis. In fringilla urna sit amet feugiat vehicula. Cras nec lectus ex. Fusce vehicula vulputate rutrum. Mauris congue ex elit, eu tempor tortor eleifend ac.