C
C
crdrads2018-12-18 15:20:16
css
crdrads, 2018-12-18 15:20:16

Use only width for flexbox grid norms?

What are the consequences if you use not the flex-basisgood old one for the grid width?
I got hooked on TailwindCSS and there they only come out of the box width. Of course, you can write down the classes for adjusting the width yourself, like in Bootstrap, but it became interesting, but what the hell is the difference?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Ankhena, 2018-12-18
@crdrads

There will be no difference until you turn the main axis. For example, when adapting to mobile sizes.
In the case of the width, the specified value will remain the width. And in the case of basis will be the height.
I usually don't change the direction of the axis, just change the width or basis. In the case of the grid, it will most likely be the same, but you need to look at how the specific one is arranged.
Those. conclusion: if there is no rotation of the main axis, then it makes no difference.
Sandbox for the horizontal main axis: https://jsfiddle.net/Ls3mdfa5/ In it, you can experiment with different shrink, grow and cell contents, while the average has a width in one case, in another basis.

V
Vladislav Lyskov, 2018-12-18
@Vlatqa

What is the difference between flex-basis and width?

F
Flying, 2018-12-18
@Flying

The difference is that it widthdetermines the strictly defined size of the element - its size along the X axis, while it flex-basisdetermines the size of the element along the main axis of the flexbox container. If flex-directionit matters rowor row-reverse- there is no difference, but if this property matters columnor column-reverse- the difference is fundamental. All this is in the documentation .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question