Template:Flex columns

From OpenStreetMap Wiki
Jump to navigation Jump to search
[Edit] [Purge] Template-info.svg Template documentation

This template creates a column layout, where contents within the columns will have the same height, with any extra whitespace distributed throughout the shorter columns contents. It is mainly intended for use in portals.

This sort of layout requires browsers to support CSS flexbox. For those that don't there is a fallback that will show a two column view, but without the heights being the same (a layout many portals used as at July 2018).

For narrow screens, e.g. mobile devices, the display reverts to a single column.

Usage

{{Flex columns
|1 = (...first column contents...)
|2 = (...second column contents...)
}}

Only contents which are in <div>}} tags will have extra whitespace distributed to them – except for those with class flex-columns-noflex (or otherwise override the flex: property)

To change the column balance, |flex1 = and/or |flex2 = can be set. The default for each is 1. For example:

  • |flex1=3 |flex2=2 will result in the first column taking up to 60% (3/5) of the available width, and the second column taking up at least 40% (2/5) of the width.

Note that the actual column balance will vary depending on screen size, since the minimum width of each column is set at 360px.

Example

{{Flex columns | {{lorem ipsum}} | {{lorem ipsum}} }}
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim.
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim.

History

This template is a derived work. It is, however, NOT exactly the same as Wikipedia's template of the same name! All CSS has been integrated into the template, and therefore some features are not available. However it is still a very useful template!