Hi guys,
I’ve got a suggestion, but with a solution already So I thought I’d share it here with you.
The problem:
Currently, there is not very intuitive way of controlling how the columns would be stacked on smaller screens, as far as I know. Take 4 columned row, for example. Once the screen is narrower it simply stacks from 4 columns layout (4 col in 1 row) into 1 column layout (1 col in 4 “rows”). I’d like to see something in between for better responsiveness. Something like 4 columns layout on desktops, 2 columns (2 cols in 2 “rows”) on tablets and 1 column layout on mobiles.
The solution:
Add additional width classes on columns to provide better targeting via CSS.
Solution via custom code in your theme:
Please note this is only PHP solution for adding the classe, I don’t provide responsive CSS here.
Put this PHP for adding additional column classes into your theme’s functions.php
file, for example.
Please note that I am not fan of the one-third
, one-half
and similar classes, so I add column width classes in this format: fl-col-width-2-3
should be read as column with width of 2/3
, so the two-thirds
width class equivalent. If the width is some custom one, there is fallback class applied - the fl-col-width-custom
.
function my_beaver_builder_column_class( $class, $col ) { // Column width class switch ( $col->settings->size ) { case '100': $class .= ' fl-col-width-1-1'; break; case '50': $class .= ' fl-col-width-1-2'; break; case '33.33': case '33.34': $class .= ' fl-col-width-1-3'; break; case '66.66': $class .= ' fl-col-width-2-3'; break; case '25': $class .= ' fl-col-width-1-4'; break; case '75': $class .= ' fl-col-width-3-4'; break; case '20': $class .= ' fl-col-width-1-5'; break; case '16.65': case '16.66': $class .= ' fl-col-width-1-6'; break; default: $class .= ' fl-col-width-custom'; break; } // Output return $class; } // /my_beaver_builder_column_class add_filter( 'fl_builder_column_custom_class', 'my_beaver_builder_column_class', 10, 2 );
Hope this will help somebody or you guys might consider adding similar width classes into a plugin future version sometimes.
I post it here in support forum 'cause it is not really a suggestion as I provide a solution already
Thanks and regards,
Oliver