Advertise Here

Using Min () and Max () in Divi 5 to create intelligent layouts

by | Apr 18, 2025 | divi, Divi resources, elegant themes, Etcetera, wordpress | 0 comments


CSS MIN () and Max () are two flexible purposes but underutilized in the design of the reactive internet and Divi 5 has a complete improvement for each because the advanced units replace. While in the past we have explored the typography of fluids with clamp () and dynamic calculations with Calc (), min () and Max () provide even more practical tactics to be successful in the reactive design.

On this send, we will show you the right way to use these purposes the use of stars (Divi 5 is ready for use on new websites, with a tip for migration for current websites that arrive quickly). The rest you will be able to do to use reactive purposes will reduce your dependence on media query, CSS is a wonderful factor!

CSS MIN () and Max (): smarter layouts with good more practical judgment

For those who have already explored the clamp (), you are halfway towards the master min () and Max ()! For those who are aware, CLUMP () uses 3 values ​​simultaneously (min, more popular and maximum), min and Max in pleal () is a similar idea, however with a single/third of the good judgment at a certain moment.

What do min () and max () do?

The MIN () and Max () purposes allow you to set two or extra values, with the smaller (min) or the larger one (max) displayed in response to the length of the display.

The “transition level” is decided respective of the 2 values ​​you put, so it is only for the display functions

Min (): always chooses the smaller price

Use Min () to prevent extended displays from the lengthening of the material of content excessively. This is superb for layouts that should not develop too extensive on huge displays, however it must have numerous flexibility to climb downwards as the display size is reduced.

 width: min(100%, 500px); 

In this case, the width of the component will never exceed 500px, however it could be 100% if it is below that 500px sign.

Max (): always chooses the highest price

Use Max () to prevent the content material from moving too much or small, in particular on smaller display or when the content material wants a minimum length to remain legible or practical. This is superb for layouts that should not narrow a defined level on small displays (a predetermined value) however it can amplify to host larger areas (with a relative value).

 width: max(80%, 300px); 

In this case, the width of the component will always be the greatest possibility: 80% of its container or 300px. On smaller displays or in narrow containers, if 80% calculate up to 300 px, the component will not however be less than 300 px. On the larger display, the component will amplify 80% of the container width, however it will not only narrow under 300px. In this way it is helping to be sure that the component remains usable on small displays while re -dizing on the larger ones.

Why mix relative and mounted values ​​in min () and max ()?

While you come across the first time on Min () or Max () in CSS, you may surprise why they regularly mix values ​​such as a proportion and a pixel. This is the result of each type of unit performs a distinct position in the reactive design.

For example, min (100px, 200px) will always arrive at the bottom of 100px. It is simply choosing the smallest of 2 values ​​mounted. However, while combining devices, such as min (100%, 500px), you are saying to the browser: “Use whatever it is smaller between 100% of the width of dad or mom and 500px”. This makes it responsive.

Relative devices such as %, VW and EM modify themselves in response to the context, regardless of whether or not it is the component of dad or mom, of the size of the hereditary characteristics. The devices mounted as PX maintain consistent in CSS, making them predictable.

By means of combining mounted and relative values, min () and Max () allow you to build versatile projects that adapt while by imposing barriers of length.

How to use Min () and Max () with Divi

Now that we have revealed the foundations of Min () and Max (), let’s talk about some examples.

1. Reactive row widths with fewer fields

You have always been able to set up a large width and width on the parts of the container with stars. However, through the opening of CSS purposes such as Min () and Max () you will be able to make the similar factor, however use a much less design box (and rather less CSS output on your web page as intelligent).

In Divi, in the event that you pass to a component (in our case, a row), the Project tab, after which a SizingTo find some choices to adjust the width. By means of the width of 95% and the atmosphere the maximum width at 900px, you may have something that appears excellent on mobile units but also provides a structure with a large number of home unfavorable on the left and adequate for desktop presentations.

Setting the line using the maximum width and width in Divi 5

It is like the use of CSS like this for lines:

 .container {
width: 95%;
max-width: 900px;
} 

With the complicated devices of Divi 5, you currently have some other extra consolidated possibility. You will be able to insert everything you want inside the simpler width box and achieve similar consequences.

By setting the line width using only MIN () in Divi 5

It is like the use of this CSS in the line container:

 .container {
width: min(95%, 900px);
} 

It is a line of CSS compared to two strains. Extra important, it requires a step and a price much less every time it uses Min () as an alternative of atmosphere each width and maximum width. Both possibilities reach the similar consequence as demonstrated in this video:

This actual use case is not so exciting, however it shows the ability of min () and max () and the way in which the oldest CSS declarations can change.

When the use of min () or max () for spacing, sizing or edges (I am able to be used on extra fields in Divi 5), I strongly advise me that they imposed them in both presets of the options group or in presets of elements. In this way, you will be able to obtain a constant downsizing regardless of the place where you use them.

2. Implementation of the row and width of the edge

Below, I have a design that deserves an extra padding inside and a larger width as larger as the size of the display become greater. To host this, I used the max () serve to set the width of the correct edge/left/best/back and padding in a row. The CSS could be a thing like this:

 .container {
padding: max(10px, 2vw) max(10px, 2vw) max(10px, 2vw) max(10px, 2vw);
border-width: max(5px, 1vw) max(5px, 1vw) max(5px, 1vw) max(5px, 1vw);
} 

For this reason the maximum () will serve how a selection will do whatever the scenario, as it is not made. The smaller padding on every aspect is 10px and the larger is 2vw. Likewise, for the width of the border, the smallest that could be is 5px and the larger is 1vw).

Here’s what Max () in this scenario looks like if in design> spacing> Padding on the line in stars:

Max () setting on the row pad in Divi UI
Here’s what Max () in this scenario looks like in design> edge> Border width on the line in stars:

Max () setting on the width of the edge in Divi UI

In combination, I have the impact of obtaining much less padding inside the row and a thinner width of the thinner on smaller display. However, it is reduced when the size of the display become larger and the worthy VW (be aware, it is a relative value) turns larger than the mounted pixel.

This is helping to maximize the supply of smaller displays, while the larger displays can fill the extra distance.

3. Complete the peak sections of heroes

The use of the min () value on the peak of a piece, you will be able to create a segment of heroes that is no less than a defined peak, however differently it adapts to 90% of the peak in full screen (and not more) the use of an easy min () serves how.

 peak: min(800px, 90vh) 

This has the impact of obtaining a full -height heroes segment excluded on larger display (higher), which could therefore view the following segment under it. In the sizing settings of the division, this can also be performed with two other inputs (large width and width), however the use of the min () serves as, we will obtain the similar impact on the use of a single box inside the sizing.

Height min on the Hero section in Divi 5

It helps to maintain the segment of heroes as a main factor for many display size, but does not transform too giant into a few circumstances with higher visualization resolutions.

4. Character dimensions

The use of minor or maximum for the size of the characters helps you to reach an extra dynamic sizing compared to the static pixels values. For this, you would like to use Max () to increase the length of the character in response to the prerequisites for the length of the display. Set the pixel/rem which is worth the small absolute length you want to use and use a relative relative to resize upwards.

1rem is the same as the length of the foundation character (generally 16px except customized for the types of web page); a length of the character of Max (1rem, 2vw) It would take the largest of the 2 values ​​and would not be smaller at all 16px.

As you will be able to see, in the smaller units, the length of the character is for 1Rem/16px. At a defined level, the largest value turns into 2vw and resize the length of the character upwards, making the character greater as the display size increases.

For the sizing of the characters, I will not recommend the use of min or max, however as an alternative clamp (). Min/Max Simple more provides you with dynamic downsizing in one path and to obtain the topic of the impact of the clamp (), you would like to set the sizing of the sizing of the min/max character in a couple of interruption points (which is imaginable, however a easier way to easily use the clamp).

Distinction between min ()/max () and pliers ()

You will be able to perceive the clamp () as a mix of min () and max () with a more popular value in the middle. Clamp () takes a value for the minimum limit, a value such as the maximum limit and a 3rd value (in the heart) as a more popular value that determines the slope of exchange between your mining and max.

An instance:

 font-size: clamp(16px, 4vw, 40px); 

This implies that the length of the character that you could be atmosphere will never be smaller than 16px or greater than 40px. In addition, the speed that adjusts (in response to the length of the display) is decided through the most popular value in the heart.

Learn my devoted article on the use of the clamp () to appear my most popular fluid typography generator that creates your designer’s purposes () for you.

Take a look at Min () and Max () with divi 5

Min () and Max () can no longer consider much such as CLUMP () or Calc (), however they are crucial gear for intelligent, more practical and cleaner projects in Divi 5.

These CSS purposes provide distinctive tactics to regulate the website reactivity. As soon as you recognize when using Min () and Max (), you will surprise the way you checked the reactive design without them. They are absolutely supported in fashionable browsers and dives makes them easy. Divi 5 is ready to be used on new websites.

Sending using Min () and Max () in Divi 5 to create intelligent layouts seemed the first on the blog of elegant themes.

wordpress maintenance plans | wordpress hosting

To find out more



Source link

thatguy
Author: thatguy

Places

Services

  • No Categories

Classifieds

  • No Categories

Events

News

Shopping