In Part 9 of our Mastering Flexbox collection, we confirmed how Column Elegance works with Structure Wrapping, Hole, Justify Content material, Align Pieces, and Show Order to create responsive multi-column layouts with out achieving for CSS Grid for each trend.
Over the process this collection, you’ve discovered the core Flexbox controls, constructed equal-height cards with aligned buttons, explored Wrap vs. No Wrap, aligned content without spacers, reordered content for better mobile flow, implemented key responsive techniques, created flexible button, menu, and link rows, switched repeated spacing from margin to Gap, and constructed responsive column patterns with Flexbox.
Now it’s time to convey the ones ways in combination. On this ultimate installment, we’ll flip probably the most helpful classes from the collection into a realistic set of highest practices. Those behavior will allow you to stay your Divi 5 layouts more straightforward to grasp, extra constant throughout breakpoints, and more practical to care for as content material adjustments.
Let’s dive in.
Why Best possible Practices Subject In Divi 5 Flexbox
In case you’ve spent years development with Divi, some older format behavior can also be arduous to wreck. Including margins to particular person modules, the usage of further Divider modules for spacing, writing customized CSS for equivalent heights, duplicating sections for various units, or depending on mounted format workarounds can have been helpful in older builds.
Divi 5’s Flexbox Structure Machine will give you local controls for lots of of the ones format jobs. Hole, Structure Course, Justify Content material, Align Pieces, and Structure Wrapping paintings on the container point to keep an eye on direct youngsters. Different controls, corresponding to Show Order, allow you to regulate the habits of particular person Flex pieces when wanted.
The objective isn’t to make use of each Flexbox surroundings on each format. It’s to construct a transparent parent-child construction, follow each and every keep an eye on on the proper point, and upload responsive overrides handiest the place the design in truth wishes them.
What Are The Advantages Of A Sturdy Flexbox Workflow?
When spacing and alignment are treated from the correct mum or dad container, similar parts are more straightforward to regulate as a gaggle. One trade to a Hole, alignment, or wrapping surroundings can have an effect on more than one youngsters with out requiring the similar edit on each module.
You’ll be able to additionally cut back duplicated format constructions and keep away from customized CSS for lots of commonplace alignment, spacing, equal-height, wrapping, and responsive ordering patterns.
Simply as importantly, reusable Flexbox sections change into more straightforward to grasp whilst you revisit them later. A Row controls its Columns, a Column controls its modules, and a Module Staff controls the similar pieces within it.
Best possible Practices And Guidelines For Flexbox
The controls you’ve discovered all the way through this collection change into a lot more helpful whilst you follow them constantly. Listed below are the practices price wearing into long term Divi 5 builds.
1. Use Hole For Repeated Spacing Between Similar Pieces
Some of the greatest workflow shifts in Divi 5 is transferring repeated spacing selections to the mum or dad container. As we coated in Part 8, use Horizontal Hole and Vertical Hole when you need constant spacing between direct baby parts.

Practice Hole to the container that immediately owns the pieces you need to house. That may well be a Segment, Row, Column, Module Group, or every other component appearing as a Flex container.
Hole creates spacing between the youngsters as a substitute of including spacing to the outer edges of the gang. That is particularly helpful when pieces wrap as a result of you’ll keep an eye on horizontal and vertical spacing from one mum or dad.
Margin nonetheless has legitimate makes use of. Succeed in for it when you want out of doors spacing on one particular component, an intentional overlap, a one-off offset, or every other impact that Hole can not create by itself.
2. Verify The Dad or mum Makes use of Flex Ahead of Adjusting Flexbox Controls
New Divi 5 bins use Flex as their default Structure Taste, however legacy Divi 4 parts and migrated layouts would possibly nonetheless use Block. If a Flexbox surroundings seems to haven’t any impact, open the component’s Design tab, increase the Structure possibility team, and test the Structure Taste first.

Simply as vital is opting for the proper container. Flexbox controls have an effect on the direct youngsters of the component you’re enhancing.
Practice them on a Row to keep an eye on its Columns.

Practice them on a Column or Module Staff to keep an eye on the modules within it.

Use them on a Nested Module when you need to keep an eye on its nested youngsters.

If a Hole or alignment surroundings isn’t affecting the weather you are expecting, ask one query first: Which component is the direct mum or dad of the pieces I need to keep an eye on?
3. Use Align Pieces > Stretch For Equivalent-Peak Playing cards
When a number of playing cards sit down at the similar Flex line and want to percentage a constant top, set Align Pieces > Stretch on their mum or dad container. Stretch is the default Align Pieces worth in Divi 5, however it’s price checking when an imported or custom designed format behaves otherwise.

In a Row with a horizontal Structure Course, Stretch works around the vertical pass axis. When the youngsters’s sizing lets in it, eligible Columns can increase to percentage the to be had top inside the similar Flex line.
This allows you to keep away from customized equal-height CSS and guide top values for lots of commonplace card layouts.
When the Row wraps onto more than one strains, take into account that each and every Flex line may have its personal top. Stretch aligns pieces inside their respective line slightly than forcing each card throughout each wrapped line to check one common top.
4. Use Area Between, Then Upload Develop To Fill When Wanted
For playing cards with a CTA that are meant to sit down close to the ground, get started via making the cardboard itself a vertical Flex container. Set its Structure Course to Column, then follow Justify Content material > Area Between.

With a Column course, the principle axis runs vertically. Area Between can stay the higher content material close to the highest whilst transferring the overall button or CTA towards the ground of the cardboard.
For simple playing cards, that can be sufficient. When variable-length content material nonetheless creates asymmetric inner spacing, use Develop To Fill at the Textual content module or Module Staff that are meant to soak up the to be had house.

Develop To Fill is a supporting instrument, no longer a demand for each card. Use it when a selected content material house must increase so the weather beneath it align extra constantly.
5. Construct Responsive Grid-Like Layouts With Structure Wrapping + Column Elegance
For plenty of card grids and repeated column patterns, one Flex Row can care for more than one strains. Allow Structure Wrapping > Wrap at the Row.

Then assign easy Column Elegance values corresponding to 1/2, 1/3, 1/4, or 2/3 to the Columns within it.

Columns stay at the similar Flex line whilst their widths and Hole values have compatibility inside the to be had house. After they now not have compatibility, Wrap lets them transfer onto further strains whilst preserving their Column Elegance values.
It is a helpful trend for responsive card grids, function sections, statistics, brand teams, and different layouts that want a herbal one-dimensional float throughout more than one strains.
6. Stay Column Elegance Combos Easy
Column Elegance will give you quite a few flexibility, however easy fractions are typically more straightforward to regulate throughout breakpoints. Get started with values corresponding to 1/2, 1/3, 1/4, 2/3, or 3/4 after they swimsuit the design.

Extra complicated combos can nonetheless be helpful, however additionally they create extra relationships to rethink when the format strikes to Pill or Telephone.
Beginning with the most straightforward construction that achieves the design makes responsive changes more straightforward to grasp later.
7. Use Construction Templates For Quicker Responsive Column Adjustments
When a number of Columns want the similar structural trade on Pill or Telephone, you don’t all the time want to edit each Column Elegance in my view.
Transfer to the objective breakpoint, open the Row’s Content material tab, increase the Parts possibility team, and click on Practice Construction Template.

A Construction Template can replace the Column Elegance association for that breakpoint in a single workflow. That is particularly helpful when a multi-column Desktop Row must change into a more practical two-column or single-column construction on smaller displays.
Use Construction Templates when the Columns percentage a transparent responsive trend. If particular person Columns want other sizing habits, adjusting their Column Elegance values one after the other would possibly nonetheless make extra sense.
8. Use Fluid Hole Variables Or Scale back Gaps At Smaller Breakpoints
Spacing that feels balanced on Desktop can really feel too beneficiant after a format wraps or stacks on Pill and Telephone. Assessment each Horizontal Hole and Vertical Hole as a part of your responsive workflow.

You’ll be able to cut back Hole values manually at particular person breakpoints, however Divi 5’s Variable Generator will give you another choice. Generate a fluid Hole sizing device and save the ensuing clamp-based values as Design Variables.
Assign the ones variables to Horizontal Hole or Vertical Hole, and the spacing can scale between outlined minimal and most values because the viewport adjustments.
You’ll be able to additionally input your individual clamp() values via Divi 5’s Complex Gadgets when you want a customized fluid courting.
Fluid sizing can cut back repetitive breakpoint overrides, whilst structural adjustments corresponding to Column Elegance, Structure Course, or Show Order can nonetheless be adjusted independently when essential.
9. Reorder Content material With Show Order Most effective When Vital
A Desktop format would possibly not all the time produce the most efficient visible collection on a smaller display screen. Divi 5’s Show Order keep an eye on allows you to visually reposition Flex pieces at particular breakpoints, together with via the usage of values corresponding to -1 to transport an merchandise previous.

Use Show Order selectively. Get started with a supply order that already is sensible as a studying and interplay collection, then upload responsive ordering handiest the place the visible hierarchy really advantages from it.
Keep in mind that visible Flexbox reordering does no longer essentially trade the record or keyboard navigation order. If interactive parts are reordered visually, check the reside web page with the keyboard to ensure center of attention nonetheless strikes in a logical collection.
10. Use Nested Modules For Tight Content material Relationships
For carefully similar parts, corresponding to a heading adopted via supporting textual content, Nested Modules can provide you with otherwise to keep an eye on their inner format with out introducing an extra outer container.
Open the mum or dad module’s Content material tab, increase the Parts possibility team, and upload the kid module within it.

As soon as nested, open the mum or dad module’s Design tab and use its Structure controls to regulate the youngsters. For instance, a small Vertical Hole can keep an eye on the connection between a Heading and nested Textual content module from one position.
Nested Modules are helpful when the weather really belong in combination. Keep away from needless nesting when a easy Column or Module Staff already supplies the construction you want.
11. Get started With A Logical Construction, Then Refine Throughout Breakpoints
Construct the clearest source-order format first. Stay the content material hierarchy logical, the parent-child relationships comprehensible, and the preliminary Flexbox settings so simple as conceivable.
Then overview the format at Pill and Telephone and upload responsive overrides handiest the place the smaller viewport wishes other habits.
Fluid values from Complex Gadgets or the Variable Generator can cut back the collection of breakpoint-specific changes wanted for spacing and typography. Structural settings, corresponding to Column Elegance, Structure Course, Structure Wrapping, or Show Order, must nonetheless be adjusted when the format wishes a real structural trade.
This assists in keeping responsive habits intentional as a substitute of gathering overrides just because they’re to be had.
12. Check Each Structure With Actual, Variable-Duration Content material
Placeholder reproduction can cover format issues. Brief headlines, lengthy headlines, multi-line descriptions, other button labels, and sundry symbol dimensions can all reveal wrapping, alignment, and spacing problems.

Check your Flexbox layouts with lifelike content material of various lengths earlier than finalizing them. Pay explicit consideration to card heights, CTA alignment, wrapping, cellular stacking order, and whether or not longer textual content adjustments the supposed hierarchy.
When variable content material creates more space within playing cards, use Develop To Fill strategically at the component that are meant to soak up that house.
Checking out content material permutations early is far more straightforward than correcting the format after actual content material has already been added around the website.
13. Use Complex Gadgets And Design Variables To Scale back Responsive Overrides
Fastened values aren’t all the time your best choice for spacing and typography throughout very other viewport sizes. Divi 5’s Advanced Units toughen purposes corresponding to clamp(), whilst the Variable Generator can create fluid sizing programs for you.
For typography, you’ll use the Variable Generator’s Font Dimension > Fluid Scale (CSS Clamp) workflow to create a reusable kind scale that grows between outlined minimal and most values.
Retailer reusable sizing values as Design Variables so the similar device can also be implemented constantly all the way through the website.

Fluid values are particularly helpful for settings that are meant to scale progressively. Breakpoint-specific values are nonetheless helpful when you want an intentional structural trade slightly than steady scaling.
14. Perceive When Align Content material If truth be told Works
Align Content material isn’t the same as Align Pieces. Align Pieces controls the pieces within each and every Flex line, whilst Align Content material controls how more than one Flex strains are dispensed alongside the pass axis.

For Align Content material to have a visual impact, the format usually wishes 3 issues:
- Structure Wrapping will have to be set to Wrap or Wrap Opposite.
- The container will have to include more than one Flex strains after the pieces wrap.
- The container will have to have more space to be had alongside the pass axis, corresponding to house created via an outlined top or minimal top.
If the content material remains on one Flex line, or the container merely grows to suit its content material, converting Align Content material would possibly seem to do not anything.
When you want to distribute more than one wrapped strains within a taller container, create the essential cross-axis house first, then make a choice an Align Content material worth corresponding to Get started, Heart, Area Between, or Area Frivolously.
15. Keep Logical Supply Order For Accessibility And Maintainability
The supply order of your parts nonetheless issues when the usage of Flexbox. Each time conceivable, construction content material in a chain that is sensible with out depending on visible reordering.
Position headings earlier than the content material they introduce, stay similar controls in combination, and ensure interactive parts practice a logical collection.

Show Order comes in handy for focused responsive presentation adjustments, nevertheless it adjustments visible placement slightly than robotically rewriting the underlying record order.
For small visible changes the place the supply collection nonetheless is sensible, that may be suitable. When you are the usage of many Show Order values to create a wholly other logical collection, rethink whether or not the underlying construction must trade as a substitute.
After reordering interactive content material, check the broadcast web page with the Tab key and ensure that the focal point collection nonetheless is sensible relative to what guests see.
16. Know When CSS Grid Is The Higher Structure Machine
Flexbox is particularly helpful when content material must float basically in a single course, distribute itself alongside an axis, wrap naturally, or reorder responsively.
CSS Grid is steadily the easier selection when the format is determined by actual two-dimensional relationships between each rows and columns.
Use Grid when you want patterns corresponding to abnormal grid maps, actual row and column placement, spanning throughout more than one tracks, intentional offsets, or layouts the place parts want to care for outlined relationships in each dimensions.
The objective isn’t to drive each design into Flexbox. Divi 5 will give you each format programs, so make a choice the person who highest fits the construction you’re looking to create.
Hanging It All In combination
The most powerful Divi 5 Flexbox layouts typically come again to a couple of core concepts: perceive the parent-child courting, use Hole for repeated inner spacing, use Stretch and Area Between the place alignment wishes it, upload Develop To Fill handiest when a selected component must soak up to be had house, and mix Structure Wrapping with Column Elegance for versatile multi-line constructions.
Use Construction Templates when more than one Columns want the similar responsive trade, use fluid Design Variables the place values must scale incessantly, and stay the underlying supply order logical earlier than including visible reordering.
Most significantly, use Flexbox as it fits the format drawback, no longer merely since the controls are to be had. When a design wishes true two-dimensional placement, transfer to CSS Grid.
This brings our Mastering Flexbox collection to a detailed. You’ll be able to start again with Part 1, revisit the examples all the way through the collection, and follow the ways for your personal layouts.
As soon as Hole, parent-level controls, responsive construction, and transparent Flexbox hierarchy change into a part of your standard workflow, complicated layouts change into more straightforward to grasp, regulate, and reuse.
The submit Part 10 Of Mastering Flexbox: Best Practices & Helpful Tips gave the impression first on Elegant Themes Blog.



0 Comments