This will be your bread and butter if you are wanting to format your guides to look good on both mobile and desktop. It will essentially replace both [columns] and [table] if your columns or tables aren't just one column.
When using the old [columns] code on small screen sizes you will find your text and images will become very narrow to try to fit everything on one row. However, with the new [responsive] columns the individual cells will change how many they show per row depending on the screen width.
Here is what a single row responsive column will look like. It is pretty simple, and similar to [table]. You have to define the container ([responsive]), define the row ([row]), and define how many cells you want with [[col]]. This is a 3 column responsive table:
Column 1
Column 2
Column 3
Code:
[responsive]
[row]
[col]Column 1[/col]
[col]Column 2[/col]
[col]Column 3[/col]
[/row]
[/responsive]
Column 1
Column 2
Column 3
code
Code:
[responsive]
[row]
[col bgcolor=#000 margin=5px padding=5px border="1px solid #1770bb"]Column 1[/col]
[col bgcolor=#000 margin=5px padding=5px border="1px solid #1770bb"]Column 2[/col]
[col bgcolor=#000 margin=5px padding=5px border="1px solid #1770bb"]Column 3[/col]
[/row]
[/responsive]
(Here is an example with bgcolor, margins, padding, and a border so it's easier to see)
The main thing to remember here is that the [col]s will only move onto a new row if there is not enough room in the current row. Let's see what happens when we make there be a full paragraph of text in the first column:
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
Column 2
Column 3
code
Code:
[responsive]
[row]
[col bgcolor=#000 margin=5px padding=5px border="1px solid #1770bb"]Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.[/col]
[col bgcolor=#000 margin=5px padding=5px border="1px solid #1770bb"]Column 2[/col]
[col bgcolor=#000 margin=5px padding=5px border="1px solid #1770bb"]Column 3[/col]
[/row]
[/responsive]
You see, the first column is very greedy with its space. Unless you define the width of the column it will just take up as much as it possibly can with the content within it. What if we want a bit more equitable column setup? Here, we will set the width of each [col] to 150px:
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
Column 2
Column 3
code
Code:
[responsive]
[row]
[col width=150 bgcolor=#000 margin=5px padding=5px border="1px solid #1770bb"]Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.[/col]
[col width=150 bgcolor=#000 margin=5px padding=5px border="1px solid #1770bb"]Column 2[/col]
[col width=150 bgcolor=#000 margin=5px padding=5px border="1px solid #1770bb"]Column 3[/col]
[/row]
[/responsive]
On desktop we get 3 evenly spaced columns in 1 row, each column being 150px. On mobile only 2 columns will fit in one row, then the last column is hanging on a second row. On mobile this looks OK, it fills the space, but on desktop it looks a bit odd since it feels like there is a lot of unused room.
A simple solution would be to use the new justify-content property on the [row]. Set justify-content to "space-evenly".
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
Column 2
Column 3
code
Code:
[responsive]
[row justify-content="space-evenly"]
[col width=150 bgcolor=#000 padding=5px border="1px solid #1770bb"]Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.[/col]
[col width=150 bgcolor=#000 padding=5px border="1px solid #1770bb"]Column 2[/col]
[col width=150 bgcolor=#000 padding=5px border="1px solid #1770bb"]Column 3[/col]
[/row]
[/responsive]
On desktop we now have a much nicer looking setup, and you'll notice on mobile column 3 is now centered, which looks a lot better and makes better use of the space. Auto margins are a simple and easy way to spread out your columns.
Now that we have the basics of responsive columns down, let's look at an example of an old column setup and how we can replicate it in the new responsive column setup.
Leave a Comment This author would like to receive feedback
and suggestions about their guide.
You need to log in before commenting.
Collapse All Comments