S
S
Sergey Goryachev2017-02-03 11:23:49
css
Sergey Goryachev, 2017-02-03 11:23:49

What is the difference between flex-basis and width?

Actually, a question in a subject, I illustrate an example.



Both options work, what's the difference?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
O
Olga Veter, 2017-02-03
@webirus

Flex-basis sets the initial size of the element relative to the main axis of the flex container. Depending on the direction of the axis, it can be similar to both width and height. Rather, even min-width and min-height. An element will not be smaller than flex-basis, but it can be larger, depending on the size of the container, window ...
Flex-basis gives much more opportunities for beautifully adapting the layout to mobile resolutions, for example, when the container stops being a row and becomes a column, or vice versa.
PS As I was rightly corrected below, flex-basis behaves differently than min-width/height in the case when it does not fit into the container, it does not "climb out".

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question