Finally! Hereās a solid and easy way to change the number of columns on mobile and tablet in Divi. By adding some custom CSS youāll get full control over how many columns to display on mobile and tablet in each Divi row.
Unlock 2-6 columns on mobile and tablet with nice spacing between and beneath the columns. This is a more robust solution then someĀ quick & dirty fixes, for exampleĀ display:flex
Ā orĀ width:50%,
that are shared in various Facebook groups and blogs. Weāll stay consistent by using the same type of code that Divi already uses for desktop columns, and apply it for smaller screens too.
In the end of the article, Iāll show how you can save time by using the theĀ Divi Global PresetsĀ to change the number of columns on mobile and tablet ā without having to add custom CSS classes to your rows.
1. Add CSS to enable multiple columns on mobile and tablet in Divi
The first step to change the number of columns in Divi for mobile and tablet is to add some custom CSS.
- Log in to your WordPress dashboard
- Go to Divi » Theme Customizer » Additional CSS
- Copy and paste the CSS below:
Pro tip:Ā Copy the entire CSS snippet to accessĀ allĀ the additional column options for mobile and tablet. If you only need one specific option, for exampleĀ 2 columns on mobile, you only need to copy that specific part of the snippet (row 3-21 below).
/*** Change Mobile Columns by https://inalbania.al ***/
/* 2 Columns Mobile */
@media all and (max-width: 767px) {
html .et-db #et-boc .two-col-mob .et_pb_column {
width:47.25% !important;
}
html .et-db #et-boc .two-col-mob .et_pb_column:nth-last-child(-n+2) {
margin-bottom:0;
}
html .et-db #et-boc .two-col-mob .et_pb_column:not(:nth-child(2n)) {
margin-right:5.5% !important;
}
}
/* 3 Columns Mobile https://inalbania.al*/
@media all and (max-width: 767px) {
html .et-db #et-boc .three-col-mob .et_pb_column {
width:29.6667% !important;
}
html .et-db #et-boc .three-col-mob .et_pb_column:nth-last-child(-n+3) {
margin-bottom:0;
}
html .et-db #et-boc .three-col-mob .et_pb_column:not(:nth-child(3n)) {
margin-right:5.5% !important;
}
}
/* 4 Columns Mobile https://inalbania.al*/
@media all and (max-width: 767px) {
html .et-db #et-boc .four-col-mob .et_pb_column {
width:20.875% !important;
}
html .et-db #et-boc .four-col-mob .et_pb_column:nth-last-child(-n+4) {
margin-bottom:0;
}
html .et-db #et-boc .four-col-mob .et_pb_column:not(:nth-child(4n)) {
margin-right:5.5% !important;
}
}
/* 5 Columns Mobile https://inalbania.al*/
@media all and (max-width: 767px) {
html .et-db #et-boc .five-col-mob .et_pb_column {
width:15.6% !important;
}
html .et-db #et-boc .five-col-mob .et_pb_column:nth-last-child(-n+5) {
margin-bottom:0;
}
html .et-db #et-boc .five-col-mob .et_pb_column:not(:nth-child(5n)) {
margin-right:5.5% !important;
}
}
/* 6 Columns Mobile https://inalbania.al*/
@media all and (max-width: 767px) {
html .et-db #et-boc .six-col-mob .et_pb_column {
width:12.083% !important;
}
html .et-db #et-boc .six-col-mob .et_pb_column:nth-last-child(-n+6) {
margin-bottom:0;
}
html .et-db #et-boc .six-col-mob .et_pb_column:not(:nth-child(6n)) {
margin-right:5.5% !important;
}
}
/*** Change Tablet Columns By https://inalbania.alĀ ***/
/* 1 Column Tablet */
@media all and (min-width: 768px) and (max-width: 980px) {
html .et-db #et-boc .one-col-tab .et_pb_column {
margin-right:0 !important;
width:100% !important;
}
html .et-db #et-boc .one-col-tab .et_pb_column:not(:last-child) {
margin-bottom:30px !important;
}
}
/* 2 Columns Tablet https://inalbania.al*/
@media all and (min-width: 768px) and (max-width: 980px) {
html .et-db #et-boc .two-col-tab .et_pb_column {
width:47.25% !important;
}
.two-col-tab .et_pb_column:nth-last-child(-n+2) {
margin-bottom:0;
}
html .et-db #et-boc .two-col-tab .et_pb_column:not(:nth-child(2n)) {
margin-right:5.5% !important;
}
}
/* 3 Columns Tablet https://inalbania.al*/
@media all and (min-width: 768px) and (max-width: 980px) {
html .et-db #et-boc .three-col-tab .et_pb_column {
width:29.6667% !important;
}
html .et-db #et-boc .three-col-tab .et_pb_column:nth-last-child(-n+3) {
margin-bottom:0;
}
html .et-db #et-boc .three-col-tab .et_pb_column:not(:nth-child(3n)) {
margin-right:5.5% !important;
}
}
/* 4 Columns Tablet https://inalbania.al*/
@media all and (min-width: 768px) and (max-width: 980px) {
html .et-db #et-boc .four-col-tab .et_pb_column {
width:20.875% !important;
}
html .et-db #et-boc .four-col-tab .et_pb_column:nth-last-child(-n+4) {
margin-bottom:0;
}
html .et-db #et-boc .four-col-tab .et_pb_column:not(:nth-child(4n)) {
margin-right:5.5% !important;
}
}
/* 5 Columns Tablet https://inalbania.al*/
@media all and (min-width: 768px) and (max-width: 980px) {
html .et-db #et-boc .five-col-tab .et_pb_column {
width:15.6% !important;
}
.five-col-mob .et_pb_column:nth-last-child(-n+5) {
margin-bottom:0;
}
html .et-db #et-boc .five-col-tab .et_pb_column:not(:nth-child(5n)) {
margin-right:5.5% !important;
}
}
/* 6 Columns Tablet https://inalbania.al*/
@media all and (min-width: 768px) and (max-width: 980px) {
html .et-db #et-boc .six-col-tab .et_pb_column {
width:12.083% !important;
}
html .et-db #et-boc .six-col-tab .et_pb_column:nth-last-child(-n+6) {
margin-bottom:0;
}
html .et-db #et-boc .six-col-tab .et_pb_column:not(:nth-child(6n)) {
margin-right:5.5% !important;
}
}
Available mobile columns options:
-
ļ1 column on mobile
- ļ2 columns on mobile
- ļ3 columns on mobile
- ļ4 columns on mobile
- ļ5 columns on mobile
- ļ6 columns on mobile
Available tablet columns options
-
ļ1 column on tablet
- ļ2 columns on tablet
- ļ3 columns on tablet
- ļ4 columns on tablet
- ļ5 columns on tablet
- ļ6 columns on tablet
2. Add CSS Classes to your Divi Rows to change the number of columns on mobile and tablet
To apply the new column count for mobile and tablet you need toĀ add the matching CSS class(es)Ā to your Divi row. That will actually take less time than reading this paragraph of text.
- Enable the Divi Visual Builder on the page that you want to edit
- Edit the row (thatās the box with the green border) by clicking the cogwheel
- Go to Advanced » CSS ID & Classes » CSS Class
- Add one or two CSS classes, matching the number of columns that you want to use, from the table below.
Please notice:Ā Sometimes, the Divi Visual Builder does not display the new column structure the correct way in backend. Save and preview in frontend to see the final result.
Number of columns
Mobile CSS class
Tablet CSS class
One
[no class needed]
one-col-tab
Two
two-col-mob
two-col-tab
Three
three-col-mob
three-col-tab
Four
four-col-mob
four-col-tab
Five
five-col-mob
five-col-tab
Six
six-col-mob
six-col-tab
The table above is actually a live example of this code using the classes āthree-col-mob three-col-tabā to display three columns on tablet and three columns on mobile (the same as on desktop).
3. Pro Tip: Use Divi Global Presets To Change Number Of Columns on Mobile And Tablet
This last step is not necessary but itās a nice way to speed up your design process by adding different mobile row structures to your Divi Global Presets library.
This way, you donāt need to add custom CSS classes each time that you want to change the number of columns in a row. Instead, you can just choose the row numbers that you want to use from theĀ Presets dropdownĀ when you add a new row.
Changing mobile row numbers with Divi Global Presets
- Make sure that you have added the custom CSS in theĀ Theme CustomizerĀ (see step 1 above)
- Create a new row on a page, a post or in a layout in the Divi Library.Ā It does not matter which column structure you choose for the row.
- Close theĀ Insert ModuleĀ modal and open theĀ Row SettingsĀ by clicking the cogwheel
- Go to Advanced » CSS ID & Classes
- Enter the CSS Class(es) that you want to add to your preset (see step 2 above) ā for exampleĀ two-col-mob four-col-tab
- Now, click theĀ Preset: DefaultĀ toggle in the purple top bar of theĀ Row Settings
- ClickĀ Create new preset from current styles
- Give your newĀ PresetĀ a clear name, for exampleĀ 2 col mob | 4 col tab
- Make sure thatĀ Assign Preset To DefaultĀ is set toĀ NOĀ and save by clicking the green checkmark button
- Repeat the process to add as manyĀ Row PresetsĀ you like.
Thatās it! To change the number of columns on mobile and tablet, just click the Preset toggle in the row settings and choose one from your list.